Skip to main content

ConnectionTracker

Struct ConnectionTracker 

Source
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

Source

pub fn new() -> Self

Create a tracker with default configuration.

Source

pub fn with_config(config: TrackerConfig) -> Self

Create a tracker with custom TrackerConfig.

Source

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.

Source

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.

Source

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.

Source

pub fn historic_len(&self) -> usize

Number of historic (recently-closed) connections.

Source

pub fn dns_analytics_snapshot(&self) -> DnsAnalyticsSnapshot

Return passive DNS analytics for the latest rolling 60-second window.

Source

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.

Source

pub fn clear(&self)

Drop all active and historic connections and reset RTT, DNS, QUIC, and learned-neighbor state.

Source

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.

Source

pub fn historic(&self) -> &HistoricMap

Direct access to the historic (recently-closed) connection table.

Source

pub fn neighbor(&self, ip: &IpAddr) -> Option<NeighborEntry>

The ARP/NDP-learned MAC/vendor mapping for ip, if one has been observed.

Source

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.

Trait Implementations§

Source§

impl Default for ConnectionTracker

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.