diff --git a/mixnet/v2/sim/node.py b/mixnet/v2/sim/node.py index 1b0b46c..1bb5dae 100644 --- a/mixnet/v2/sim/node.py +++ b/mixnet/v2/sim/node.py @@ -29,12 +29,22 @@ class Node: Creates/encapsulate a message and send it to the network through the mixnet """ while True: - msg = self.create_message() # TODO: Use the realistic cover traffic emission rate - yield self.env.timeout(2) + yield self.env.timeout(self.config.message_interval) + + if not self.is_message_sender(): + continue + + prep_time = random.uniform(0, self.config.max_message_prep_time) + yield self.env.timeout(prep_time) + self.log("Sending a message to the mixnet") + msg = self.create_message() self.env.process(self.p2p.broadcast(msg)) + def is_message_sender(self) -> bool: + return random.random() < self.config.message_prob + def create_message(self) -> SphinxPacket: """ Creates a message using the Sphinx format diff --git a/requirements.txt b/requirements.txt index 13b4439..4f54ad5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,3 +11,5 @@ simpy==4.1.1 pandas==2.2.2 matplotlib==3.8.4 seaborn==0.13.2 +pyyaml==6.0.1 +dacite==1.8.1