add message_prob and prep_time

This commit is contained in:
Youngjoon Lee 2024-05-15 16:34:09 +09:00
parent 4f6fb30779
commit 66004c60f0
No known key found for this signature in database
GPG Key ID: 09B750B5BD6F08A2
2 changed files with 14 additions and 2 deletions

View File

@ -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

View File

@ -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