add max_network_latency

This commit is contained in:
Youngjoon Lee 2024-05-16 14:04:32 +09:00
parent fb4fb48712
commit 93acaa436e
No known key found for this signature in database
GPG Key ID: 09B750B5BD6F08A2
3 changed files with 7 additions and 2 deletions

View File

@ -22,6 +22,8 @@ class Config:
cover_message_prob: float
# A maximum preparation time (delay) before sending the message
max_message_prep_time: float
# A maximum network latency between nodes directly connected with each other
max_network_latency: float
@classmethod
def load(cls, yaml_path: str) -> Self:
@ -40,5 +42,6 @@ class Config:
assert weight >= 1
assert config.cover_message_prob >= 0
assert config.max_message_prep_time >= 0
assert config.max_network_latency >= 0
return config

View File

@ -13,4 +13,6 @@ real_message_prob_weights: [10, 8, 12]
# A probability of sending a cover message within a cycle if not sending a real message
cover_message_prob: 0.2
# A maximum preparation time (delay) before sending the message
max_message_prep_time: 0.3
max_message_prep_time: 0.3
# A maximum network latency between nodes directly connected with each other
max_network_latency: 0.5

View File

@ -74,7 +74,7 @@ class Node:
@param msg: the message to be processed
"""
# simulating network latency
yield self.env.timeout(random.randint(0, 3))
yield self.env.timeout(random.uniform(0, self.config.max_network_latency))
if isinstance(msg, SphinxPacket):
msg, incentive_tx = msg.unwrap(self.private_key)