add message_prob and prep_time
This commit is contained in:
parent
4f6fb30779
commit
66004c60f0
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue