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_at(&self, parsed: &ParsedPacket, now: SystemTime) -> IngestOutcome
pub fn ingest_at(&self, parsed: &ParsedPacket, now: SystemTime) -> IngestOutcome
Fold a parsed packet into the connection table, creating or updating the
matching connection, stamping the update with the supplied now.
Pass the packet’s own capture timestamp: for offline processing (pcap
replay, tests) this keeps created_at/last_activity and the
cleanup timeout sweep on trace time rather than the
replay wall clock. Live callers should also pass each packet’s own
capture timestamp, not one clock read shared across a batch of packets.
Handshake RTT is the difference between two packets’ now values, so a
shared timestamp collapses every round trip that completes within one
batch to zero.
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 with_retained_sources<R>(
&self,
inspect: impl FnOnce(&ConnectionMap, &HistoricMap) -> R,
) -> R
pub fn with_retained_sources<R>( &self, inspect: impl FnOnce(&ConnectionMap, &HistoricMap) -> R, ) -> R
Inspect the active and historic maps as one consistent retained view.
Cleanup cannot move a connection between the maps while inspect is
running. Packet updates may still update active rows through DashMap’s
per-entry locking.
Sourcepub fn historic_len(&self) -> usize
pub fn historic_len(&self) -> usize
Number of historic (recently-closed) connections.
Sourcepub fn dns_analytics_snapshot(&self) -> DnsAnalyticsSnapshot
pub fn dns_analytics_snapshot(&self) -> DnsAnalyticsSnapshot
Return passive DNS analytics for the latest rolling 60-second window.
Sourcepub fn dns_analytics_snapshot_at(&self, now: SystemTime) -> DnsAnalyticsSnapshot
pub fn dns_analytics_snapshot_at(&self, now: SystemTime) -> DnsAnalyticsSnapshot
Return passive DNS analytics relative to a supplied capture time. Offline consumers can use this to keep the window aligned with a replayed trace instead of wall-clock time.
Sourcepub fn clear(&self)
pub fn clear(&self)
Drop all active and historic connections and reset RTT, DNS, QUIC, and learned-neighbor state.
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_at 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 neighbor(&self, ip: &IpAddr) -> Option<NeighborEntry>
pub fn neighbor(&self, ip: &IpAddr) -> Option<NeighborEntry>
The ARP/NDP-learned MAC/vendor mapping for ip, if one has been
observed.
Sourcepub fn take_average_rtt(&self, window_secs: u64) -> Option<f64>
pub fn take_average_rtt(&self, window_secs: u64) -> Option<f64>
Average network RTT (in milliseconds) over the last window_secs
seconds of handshake, TCP data, and ICMP echo samples. None if no
samples are available.