Skip to content

Commit 4c166f0

Browse files
committed
chore(docs): documentation
1 parent 24ef990 commit 4c166f0

4 files changed

Lines changed: 73 additions & 5 deletions

File tree

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/stackforge-core/src/flow/mod.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,18 @@ pub fn extract_flows_with_config(
174174
format_duration(elapsed),
175175
format_count(rate as usize)
176176
);
177+
178+
let (total_drops, flows_with_drops) = count_dropped_segments(&conversations);
179+
if total_drops > 0 {
180+
eprintln!(
181+
"[!] Warning: {} TCP segments dropped across {} flows (buffer/fragment limits exceeded)",
182+
format_count(total_drops as usize),
183+
format_count(flows_with_drops),
184+
);
185+
eprintln!(
186+
"[!] Tip: increase max_reassembly_buffer or max_ooo_fragments to capture more data"
187+
);
188+
}
177189
eprintln!();
178190
}
179191
Ok(conversations)
@@ -265,11 +277,40 @@ where
265277
format_count(conversations.len())
266278
);
267279
eprintln!("[+] Wall time: {}", format_duration(elapsed));
280+
281+
// Report reassembly drops
282+
let (total_drops, flows_with_drops) = count_dropped_segments(&conversations);
283+
if total_drops > 0 {
284+
eprintln!(
285+
"[!] Warning: {} TCP segments dropped across {} flows (buffer/fragment limits exceeded)",
286+
format_count(total_drops as usize),
287+
format_count(flows_with_drops),
288+
);
289+
eprintln!(
290+
"[!] Tip: increase max_reassembly_buffer or max_ooo_fragments to capture more data"
291+
);
292+
}
268293
eprintln!();
269294
}
270295
Ok(conversations)
271296
}
272297

298+
/// Count total dropped TCP segments across all conversations.
299+
fn count_dropped_segments(conversations: &[ConversationState]) -> (u64, usize) {
300+
let mut total_drops: u64 = 0;
301+
let mut flows_with_drops: usize = 0;
302+
for conv in conversations {
303+
if let ProtocolState::Tcp(ref tcp) = conv.protocol_state {
304+
let drops = tcp.total_dropped_segments();
305+
if drops > 0 {
306+
total_drops += drops;
307+
flows_with_drops += 1;
308+
}
309+
}
310+
}
311+
(total_drops, flows_with_drops)
312+
}
313+
273314
/// Extract flows directly from a capture file (PCAP or PcapNG).
274315
///
275316
/// Streams packets from disk — never loads the entire file into memory.

crates/stackforge-core/src/flow/table.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,7 @@ impl ConversationTable {
182182

183183
if let ProtocolState::Tcp(ref mut tcp_state) = entry.value_mut().protocol_state {
184184
// Skip buffers already on disk
185-
if tcp_state.reassembler_fwd.is_spilled()
186-
&& tcp_state.reassembler_rev.is_spilled()
185+
if tcp_state.reassembler_fwd.is_spilled() && tcp_state.reassembler_rev.is_spilled()
187186
{
188187
consecutive_skips += 1;
189188
continue;

src/lib.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4254,6 +4254,34 @@ impl PyConversation {
42544254
}
42554255
}
42564256

4257+
/// Number of TCP segments dropped due to reassembly buffer/fragment limits.
4258+
/// Returns 0 for non-TCP flows.
4259+
#[getter]
4260+
fn dropped_segments(&self) -> u64 {
4261+
match &self.inner.protocol_state {
4262+
stackforge_core::ProtocolState::Tcp(tcp) => tcp.total_dropped_segments(),
4263+
_ => 0,
4264+
}
4265+
}
4266+
4267+
/// Number of forward-direction TCP segments dropped.
4268+
#[getter]
4269+
fn dropped_segments_fwd(&self) -> u64 {
4270+
match &self.inner.protocol_state {
4271+
stackforge_core::ProtocolState::Tcp(tcp) => tcp.dropped_segments_fwd,
4272+
_ => 0,
4273+
}
4274+
}
4275+
4276+
/// Number of reverse-direction TCP segments dropped.
4277+
#[getter]
4278+
fn dropped_segments_rev(&self) -> u64 {
4279+
match &self.inner.protocol_state {
4280+
stackforge_core::ProtocolState::Tcp(tcp) => tcp.dropped_segments_rev,
4281+
_ => 0,
4282+
}
4283+
}
4284+
42574285
/// Z-Wave home ID, or None for non-Z-Wave flows.
42584286
#[getter]
42594287
fn zwave_home_id(&self) -> Option<u32> {

0 commit comments

Comments
 (0)