pub struct ConnectionTracker { /* private fields */ }Expand description
A live, lifecycle-managed table of network connections built from parsed packets. See the module docs for the intended usage.
Implementations§
Source§impl ConnectionTracker
impl ConnectionTracker
Sourcepub fn with_config(config: TrackerConfig) -> Self
pub fn with_config(config: TrackerConfig) -> Self
Create a tracker with custom TrackerConfig.
Sourcepub fn ingest(&self, parsed: &ParsedPacket) -> IngestOutcome
pub fn ingest(&self, parsed: &ParsedPacket) -> IngestOutcome
Fold a parsed packet into the connection table, creating or updating the matching connection, timestamping the update with the current wall clock.
This is the right call for live capture. Offline consumers replaying a
pcap should use ingest_at and pass the packet’s own
capture time so connection lifetimes and cleanup
timeouts reflect the trace rather than the replay wall clock.
Sourcepub fn ingest_at(&self, parsed: &ParsedPacket, now: SystemTime) -> IngestOutcome
pub fn ingest_at(&self, parsed: &ParsedPacket, now: SystemTime) -> IngestOutcome
Like ingest, but stamps the connection update with the
supplied now instead of the wall clock.
Use this for deterministic offline processing (pcap replay, tests): pass
the packet’s capture timestamp so created_at/last_activity and the
cleanup timeout sweep operate on trace time, not real time.
Sourcepub fn cleanup(&self, now: SystemTime) -> Vec<Connection>
pub fn cleanup(&self, now: SystemTime) -> Vec<Connection>
Remove connections whose protocol-aware timeout has elapsed as of now.
Removed connections are archived into the historic table (when
keep_historic is set, subject to
max_historic eviction) and their QUIC
mappings are dropped. Returns the removed connections (in their original,
pre-archive form) so callers can emit close events or export them.
Sourcepub fn snapshot(&self) -> Vec<Connection>
pub fn snapshot(&self) -> Vec<Connection>
A point-in-time copy of the active connections.
Note: this is a full clone, including each connection’s rate-sample
buffer — the buffer is shared via Arc, so the next per-packet
update on a live connection pays a copy-on-write deep copy. Callers
that only need the cached current_*_rate_bps fields (any read-only
view) should prefer Connection::snapshot_clone over the entries of
connections to keep the packet path allocation-
free.
Sourcepub fn historic_snapshot(&self) -> Vec<Connection>
pub fn historic_snapshot(&self) -> Vec<Connection>
A point-in-time copy of the historic (recently-closed) connections.
Sourcepub fn historic_len(&self) -> usize
pub fn historic_len(&self) -> usize
Number of historic (recently-closed) connections.
Sourcepub fn config(&self) -> &TrackerConfig
pub fn config(&self) -> &TrackerConfig
The tracker’s configuration.
Sourcepub fn connections(&self) -> &ConnectionMap
pub fn connections(&self) -> &ConnectionMap
Direct access to the active connection table.
Use this for in-place enrichment (e.g. attaching process, DNS, or GeoIP
information via iter_mut) or custom reads. Lifecycle changes should go
through ingest and cleanup so the
connection-count limit, RTT, and QUIC coalescing stay consistent —
inserting or removing entries directly desyncs the internal counter
backing the max_connections check.
Sourcepub fn historic(&self) -> &HistoricMap
pub fn historic(&self) -> &HistoricMap
Direct access to the historic (recently-closed) connection table.
Sourcepub fn take_average_rtt(&self, window_secs: u64) -> Option<f64>
pub fn take_average_rtt(&self, window_secs: u64) -> Option<f64>
Average RTT (in milliseconds) over the last window_secs seconds of
SYN/SYN-ACK samples, consuming the samples in that window. None if no
samples are available.