pub struct Framework<M, R, T = Instant>where
T: Instant,{ /* private fields */ }
Expand description
An instance of the Maybenot framework.
An instance of the Framework
repeatedly takes as input one or more
TriggerEvent
describing the encrypted traffic going over an encrypted
channel, and produces as output zero or more TriggerAction
, such as to
send padding traffic or block outgoing traffic. One or more Machine
determine what TriggerAction
to take based on TriggerEvent
.
Implementations§
Source§impl<M, R, T> Framework<M, R, T>
impl<M, R, T> Framework<M, R, T>
Sourcepub fn new(
machines: M,
max_padding_frac: f64,
max_blocking_frac: f64,
current_time: T,
rng: R,
) -> Result<Self, Error>
pub fn new( machines: M, max_padding_frac: f64, max_blocking_frac: f64, current_time: T, rng: R, ) -> Result<Self, Error>
Create a new framework instance with zero or more Machine
.
The max padding/blocking fractions are enforced as a total across all machines.
The only way those limits can be violated are through
Machine::allowed_padding_packets
and
Machine::allowed_blocked_microsec
, respectively.
The current time is handed to the framework here (and later in Self::trigger_events()
)
to make some types of use cases of the framework easier (weird machines and
for simulation). The generic time type also allows for using custom time sources.
This can for example improve performance.
Returns an error on any invalid Machine
or limits not being fractions [0.0, 1.0].
Sourcepub fn num_machines(&self) -> usize
pub fn num_machines(&self) -> usize
Returns the number of machines in the framework.
Sourcepub fn trigger_events(
&mut self,
events: &[TriggerEvent],
current_time: T,
) -> impl Iterator<Item = &TriggerAction<T>>
pub fn trigger_events( &mut self, events: &[TriggerEvent], current_time: T, ) -> impl Iterator<Item = &TriggerAction<T>>
Trigger zero or more TriggerEvent
for all machines running in the
framework.
The current_time
SHOULD be the current time at the time of calling the
method (e.g., Instant::now()
).
In more detail, the current_time
SHOULD be a monotonically
nondecreasing clock. This means that the time passed SHOULD never be
earlier than what was given to Framework::new()
or a previous call
to trigger_events
for the same framework instance. If this requirement
is not followed, blocking durations MAY be inaccurately accounted for,
leading to less or more TriggerAction::BlockOutgoing
than intended
by set framework and machine limits. The consequences of this depend on
the running machines (e.g., a machine may also pad as a consequence of
blocking) and the use-case for the user of the framework.
Returns an iterator of zero or more TriggerAction
that MUST be taken
by the caller.