diff --git a/.cargo-ok b/.cargo-ok new file mode 100644 index 00000000000..e69de29bb2d diff --git a/common/client-core/src/client/cover_traffic_stream.rs b/common/client-core/src/client/cover_traffic_stream.rs index d10a6b04dcd..236c9ab37ed 100644 --- a/common/client-core/src/client/cover_traffic_stream.rs +++ b/common/client-core/src/client/cover_traffic_stream.rs @@ -90,7 +90,6 @@ where // Get the `now` by looking at the current `delay` deadline let avg_delay = self.cover_traffic.loop_cover_traffic_average_delay; let next_poisson_delay = sample_poisson_duration(&mut self.rng, avg_delay); - // The next interval value is `next_poisson_delay` after the one that just // yielded. let now = self.next_delay.deadline(); @@ -179,7 +178,6 @@ impl LoopCoverTrafficStream { return; } }; - let cover_message = match generate_loop_cover_packet( &mut self.rng, self.use_legacy_sphinx_format, @@ -187,7 +185,7 @@ impl LoopCoverTrafficStream { &self.ack_key, &self.our_full_destination, self.average_ack_delay, - self.cover_traffic.loop_cover_traffic_average_delay, + self.average_ack_delay, cover_traffic_packet_size, self.packet_type, ) { @@ -238,14 +236,12 @@ impl LoopCoverTrafficStream { // so panic and review the code that lead to this branch panic!("attempted to run LoopCoverTrafficStream while config explicitly disabled it.") } - // we should set initial delay only when we actually start the stream let sampled = sample_poisson_duration( &mut self.rng, self.cover_traffic.loop_cover_traffic_average_delay, ); self.set_next_delay(sampled); - while self.next().await.is_some() { self.on_new_message().await; } diff --git a/common/client-core/src/client/real_messages_control/mod.rs b/common/client-core/src/client/real_messages_control/mod.rs index 9b852535fa9..4c1a9f9acd8 100644 --- a/common/client-core/src/client/real_messages_control/mod.rs +++ b/common/client-core/src/client/real_messages_control/mod.rs @@ -205,7 +205,6 @@ impl RealMessagesController { stats_tx, shutdown_token.clone(), ); - RealMessagesController { out_queue_control, ack_control, diff --git a/common/client-core/src/client/real_messages_control/real_traffic_stream.rs b/common/client-core/src/client/real_messages_control/real_traffic_stream.rs index 92faffdbf23..249afd30ee8 100644 --- a/common/client-core/src/client/real_messages_control/real_traffic_stream.rs +++ b/common/client-core/src/client/real_messages_control/real_traffic_stream.rs @@ -248,7 +248,6 @@ where return; } }; - // SAFETY: our topology must be valid at this point #[allow(clippy::expect_used)] ( @@ -437,7 +436,6 @@ where // we know it's time to send a message, so let's prepare delay for the next one // Get the `now` by looking at the current `delay` deadline let next_poisson_delay = sample_poisson_duration(&mut self.rng, avg_delay); - // The next interval value is `next_poisson_delay` after the one that just // yielded. let now = next_delay.deadline(); diff --git a/common/nymsphinx/src/preparer/mod.rs b/common/nymsphinx/src/preparer/mod.rs index 038f1c4b7a4..563cc005a2f 100644 --- a/common/nymsphinx/src/preparer/mod.rs +++ b/common/nymsphinx/src/preparer/mod.rs @@ -250,7 +250,6 @@ pub trait FragmentPreparer { }; let destination = packet_recipient.as_sphinx_destination(); - // including set of delays let delays = nym_sphinx_routing::generate_hop_delays(self.average_packet_delay(), route.len()); diff --git a/nym-registration-client/src/builder/config.rs b/nym-registration-client/src/builder/config.rs index be26f9e6924..5c343f09875 100644 --- a/nym-registration-client/src/builder/config.rs +++ b/nym-registration-client/src/builder/config.rs @@ -41,7 +41,7 @@ pub struct BuilderConfig { pub connection_fd_callback: Arc, } -#[derive(Clone, Default, Debug, Eq, PartialEq)] +#[derive(Clone, Default, Debug, PartialEq)] pub struct MixnetClientConfig { /// Disable Poission process rate limiting of outbound traffic. pub disable_poisson_rate: bool, @@ -54,6 +54,13 @@ pub struct MixnetClientConfig { /// The minimum performance of gateways to use. pub min_gateway_performance: Option, + ///Setting optionally the poisson rate for cover traffic stream + pub poisson_rate: Option, + /// Average packet delay in milliseconds. + pub average_packet_delay: Option, + + /// Average message sending delay in milliseconds. + pub message_sending_average_delay: Option, } impl BuilderConfig { @@ -151,7 +158,15 @@ fn two_hop_debug_config(mixnet_client_config: &MixnetClientConfig) -> DebugConfi if let Some(min_gateway_performance) = mixnet_client_config.min_gateway_performance { debug_config.topology.minimum_gateway_performance = min_gateway_performance; } + if let Some(avg_packet_ms) = mixnet_client_config.average_packet_delay { + debug_config.traffic.average_packet_delay = Duration::from_millis(avg_packet_ms as u64); + debug_config.acknowledgements.average_ack_delay = Duration::from_millis(avg_packet_ms as u64); + + } + if let Some(msg_delay_ms) = mixnet_client_config.message_sending_average_delay { + debug_config.traffic.message_sending_average_delay = Duration::from_millis(msg_delay_ms as u64); + } log_mixnet_client_config(&debug_config); debug_config } @@ -166,7 +181,11 @@ fn mixnet_debug_config(mixnet_client_config: &MixnetClientConfig) -> DebugConfig debug_config.cover_traffic.disable_loop_cover_traffic_stream = mixnet_client_config.disable_background_cover_traffic; + if let Some(poisson_rate) = mixnet_client_config.poisson_rate { + let duration = std::time::Duration::from_millis((poisson_rate as f64).round() as u64); + debug_config.cover_traffic.loop_cover_traffic_average_delay = duration; + } if let Some(min_mixnode_performance) = mixnet_client_config.min_mixnode_performance { debug_config.topology.minimum_mixnode_performance = min_mixnode_performance; } @@ -174,6 +193,14 @@ fn mixnet_debug_config(mixnet_client_config: &MixnetClientConfig) -> DebugConfig if let Some(min_gateway_performance) = mixnet_client_config.min_gateway_performance { debug_config.topology.minimum_gateway_performance = min_gateway_performance; } + if let Some(avg_packet_ms) = mixnet_client_config.average_packet_delay { + debug_config.traffic.average_packet_delay = Duration::from_millis(avg_packet_ms as u64); + debug_config.acknowledgements.average_ack_delay=Duration::from_millis(avg_packet_ms as u64); + } + + if let Some(msg_delay_ms) = mixnet_client_config.message_sending_average_delay { + debug_config.traffic.message_sending_average_delay = Duration::from_millis(msg_delay_ms as u64); + } log_mixnet_client_config(&debug_config); debug_config }