pub struct StreamBuffer {
pub segment_count: u32,
pub retransmit_count: u32,
pub out_of_order_count: u32,
pub fin_received: bool,
/* private fields */
}Expand description
Buffer for one direction of a TCP stream.
Fields§
§segment_count: u32Statistics.
retransmit_count: u32§out_of_order_count: u32§fin_received: boolFIN received.
Implementations§
Source§impl StreamBuffer
impl StreamBuffer
pub fn new() -> Self
Sourcepub fn set_initial_seq(&mut self, seq: u32)
pub fn set_initial_seq(&mut self, seq: u32)
Set the initial sequence number (from SYN).
Sourcepub fn add_inorder_data(
&mut self,
seq: u32,
data: &[u8],
_frame_number: u64,
_timestamp: i64,
) -> bool
pub fn add_inorder_data( &mut self, seq: u32, data: &[u8], _frame_number: u64, _timestamp: i64, ) -> bool
Fast path for in-order segment - avoids intermediate Vec allocation. Returns true if the segment was handled (in-order with no pending segments). Returns false if the segment needs to be handled by the slow path.
This copies data directly into the reassembled buffer, avoiding the
intermediate Segment { data: data.to_vec(), ... } allocation that
the slow path requires.
Sourcepub fn add_segment(&mut self, segment: Segment)
pub fn add_segment(&mut self, segment: Segment)
Add a segment to the buffer (slow path - takes ownership).
Sourcepub fn get_contiguous(&self) -> &[u8] ⓘ
pub fn get_contiguous(&self) -> &[u8] ⓘ
Get contiguous reassembled data.
Sourcepub fn consume(&mut self, bytes: usize)
pub fn consume(&mut self, bytes: usize)
Consume bytes from the reassembled buffer (after successful parse).
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Check if stream is complete (no gaps, FIN received).
Sourcepub fn gaps(&self) -> &[SequenceGap]
pub fn gaps(&self) -> &[SequenceGap]
Get current gaps in the stream.
Sourcepub fn record_gap(&mut self, start: u32, end: u32)
pub fn record_gap(&mut self, start: u32, end: u32)
Record a gap when we detect missing data.
Sourcepub fn segment_count(&self) -> u32
pub fn segment_count(&self) -> u32
Get the segment count.
Sourcepub fn retransmit_count(&self) -> u32
pub fn retransmit_count(&self) -> u32
Get the retransmission count.
Sourcepub fn out_of_order_count(&self) -> u32
pub fn out_of_order_count(&self) -> u32
Get the out-of-order segment count.