2024-05-15 07:36:13 +00:00
|
|
|
import random
|
|
|
|
|
2024-05-09 05:29:10 +00:00
|
|
|
import simpy
|
|
|
|
|
2024-05-14 12:19:46 +00:00
|
|
|
from config import Config
|
2024-05-12 23:49:09 +00:00
|
|
|
from node import Node
|
|
|
|
from p2p import P2p
|
2024-05-09 10:37:39 +00:00
|
|
|
|
2024-05-09 05:29:10 +00:00
|
|
|
|
|
|
|
class Simulation:
|
2024-05-14 12:19:46 +00:00
|
|
|
def __init__(self, config: Config):
|
2024-05-15 07:36:13 +00:00
|
|
|
random.seed()
|
2024-05-14 12:19:46 +00:00
|
|
|
self.config = config
|
2024-05-09 05:29:10 +00:00
|
|
|
self.env = simpy.Environment()
|
2024-05-15 09:01:42 +00:00
|
|
|
self.p2p = P2p(self.env, config)
|
2024-05-17 05:54:23 +00:00
|
|
|
self.nodes = [Node(i, self.env, self.p2p, config) for i in range(config.mixnet.num_nodes)]
|
2024-05-09 10:37:39 +00:00
|
|
|
self.p2p.add_node(self.nodes)
|
2024-05-09 05:29:10 +00:00
|
|
|
|
2024-05-14 12:19:46 +00:00
|
|
|
def run(self):
|
2024-05-17 05:54:23 +00:00
|
|
|
self.env.run(until=self.config.simulation.running_time)
|