Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .cargo-ok
Empty file.
16 changes: 11 additions & 5 deletions common/client-core/src/client/cover_traffic_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ 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);

println!(
"[DEBUG] LoopCoverStream: Next loop cover traffic packet in {:?} (average = {:?})",
next_poisson_delay, avg_delay
);
// The next interval value is `next_poisson_delay` after the one that just
// yielded.
let now = self.next_delay.deadline();
Expand Down Expand Up @@ -179,15 +182,14 @@ impl LoopCoverTrafficStream<OsRng> {
return;
}
};

let cover_message = match generate_loop_cover_packet(
&mut self.rng,
self.use_legacy_sphinx_format,
topology_ref,
&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,
) {
Expand Down Expand Up @@ -238,14 +240,18 @@ impl LoopCoverTrafficStream<OsRng> {
// so panic and review the code that lead to this branch
panic!("attempted to run LoopCoverTrafficStream while config explicitly disabled it.")
}

// println!("Sampled poisson duration");
// 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);

println!(
"[DEBUG] LoopCoverTrafficStream initialized with average delay {:?} (sampled = {:?})",
self.cover_traffic.loop_cover_traffic_average_delay,
sampled
);
while self.next().await.is_some() {
self.on_new_message().await;
}
Expand Down
2 changes: 1 addition & 1 deletion common/client-core/src/client/real_messages_control/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl RealMessagesController<OsRng> {
stats_tx,
shutdown_token.clone(),
);

println!("average packet delay {:?} message sending delay {:?}",config.traffic.average_packet_delay,config.traffic.message_sending_average_delay);
RealMessagesController {
out_queue_control,
ack_control,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ where
return;
}
};

println!("real_traffic_stream on message average delay {:?}",self.config.traffic.average_packet_delay);
// SAFETY: our topology must be valid at this point
#[allow(clippy::expect_used)]
(
Expand Down Expand Up @@ -437,7 +437,7 @@ 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);

println!("Sample poisson average delay: {:?} and sampled {:?}",avg_delay,next_poisson_delay);
// The next interval value is `next_poisson_delay` after the one that just
// yielded.
let now = next_delay.deadline();
Expand Down Expand Up @@ -468,6 +468,7 @@ where
if let Some(real_next) = self.pop_next_message() {
Poll::Ready(Some(StreamMessage::Real(Box::new(real_next))))
} else {
// println!("Sending cover traffic");
// otherwise construct a dummy one
Poll::Ready(Some(StreamMessage::Cover))
}
Expand Down Expand Up @@ -529,8 +530,10 @@ where
cx: &mut Context<'_>,
) -> Poll<Option<StreamMessage>> {
if self.config.traffic.disable_main_poisson_packet_distribution {
println!("Real traffic stream polls without poisson rate");
self.poll_immediate(cx)
} else {
println!("Real traffic stream polls with poisson rate");
self.poll_poisson(cx)
}
}
Expand Down
1 change: 1 addition & 0 deletions common/nymsphinx/anonymous-replies/src/reply_surb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ impl ReplySurb {
} else {
topology.random_route_to_egress(rng, recipient.gateway())?
};
println!("reply_surbs.rs average delay: {:?}",average_delay);
let delays = nym_sphinx_routing::generate_hop_delays(average_delay, route.len());
let destination = recipient.as_sphinx_destination();

Expand Down
1 change: 1 addition & 0 deletions common/nymsphinx/cover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ where
.collect();

let route = topology.random_route_to_egress(rng, full_address.gateway())?;
println!("Average packet delays in cover/src/lib.rs {:?}",average_packet_delay);
let delays = nym_sphinx_routing::generate_hop_delays(average_packet_delay, route.len());
let destination = full_address.as_sphinx_destination();

Expand Down
2 changes: 1 addition & 1 deletion common/nymsphinx/src/preparer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub trait FragmentPreparer {
};

let destination = packet_recipient.as_sphinx_destination();

println!("src/peparer/mod.rs average delay {:?}",self.average_packet_delay());
// including set of delays
let delays =
nym_sphinx_routing::generate_hop_delays(self.average_packet_delay(), route.len());
Expand Down
30 changes: 29 additions & 1 deletion nym-registration-client/src/builder/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct BuilderConfig {
pub connection_fd_callback: Arc<dyn Fn(RawFd) + Send + Sync>,
}

#[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,
Expand All @@ -54,6 +54,13 @@ pub struct MixnetClientConfig {

/// The minimum performance of gateways to use.
pub min_gateway_performance: Option<u8>,
///Setting optionally the poisson rate for cover traffic stream
pub poisson_rate: Option<f32>,
/// Average packet delay in milliseconds.
pub average_packet_delay: Option<f32>,

/// Average message sending delay in milliseconds.
pub message_sending_average_delay: Option<f32>,
}

impl BuilderConfig {
Expand Down Expand Up @@ -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
}
Expand All @@ -166,14 +181,27 @@ 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;

println!("Debug config has {:?} duration:",duration);
}
if let Some(min_mixnode_performance) = mixnet_client_config.min_mixnode_performance {
debug_config.topology.minimum_mixnode_performance = min_mixnode_performance;
}

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
}
Expand Down
Loading