mirror of
https://github.com/logos-blockchain/logos-blockchain-specs.git
synced 2026-01-08 16:13:10 +00:00
remove measuring broadcasters
This commit is contained in:
parent
a6d12dba64
commit
eb864dda33
@ -1,9 +1,7 @@
|
||||
from collections import Counter
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import scipy.stats as stats
|
||||
import seaborn
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
@ -226,34 +224,6 @@ class Analysis:
|
||||
plt.xlim(-1, self.config.mixnet.num_nodes)
|
||||
plt.show()
|
||||
|
||||
# Create the bar plot for broadcasters
|
||||
broadcasters = ({node.id: count for node, count in self.sim.p2p.broadcasters.items()})
|
||||
plt.figure(figsize=(12, 8))
|
||||
plt.bar(list(broadcasters.keys()), list(broadcasters.values()))
|
||||
plt.xlabel("Node ID")
|
||||
plt.ylabel("Counts")
|
||||
plt.title("Broadcasters")
|
||||
plt.xlim(-1, self.config.mixnet.num_nodes)
|
||||
plt.show()
|
||||
|
||||
# Calculate the mean and standard deviation of the counts
|
||||
mean = np.mean(values)
|
||||
std_dev = np.std(values)
|
||||
# Plot the histogram of the values
|
||||
plt.figure(figsize=(12, 8))
|
||||
plt.hist(values, bins=30, density=True, alpha=0.6, color="g", label="Counts Histogram")
|
||||
# Plot the normal distribution curve
|
||||
xmin, xmax = plt.xlim()
|
||||
x = np.linspace(xmin, xmax, 100)
|
||||
p = stats.norm.pdf(x, mean, std_dev)
|
||||
plt.plot(x, p, "k", linewidth=2, label="Normal Distribution")
|
||||
title = "Fit results: mean = %.2f, std_dev = %.2f" % (mean, std_dev)
|
||||
plt.title(title)
|
||||
plt.xlabel("Counts")
|
||||
plt.ylabel("Density")
|
||||
plt.legend()
|
||||
plt.show()
|
||||
|
||||
def timing_attack_with(self, receiver: "Node", window: int, remaining_hops: int, sender: "Node" = None) -> Counter:
|
||||
assert remaining_hops >= 1
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
import hashlib
|
||||
import random
|
||||
from abc import ABC, abstractmethod
|
||||
from collections import defaultdict, Counter
|
||||
from collections import defaultdict
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import simpy
|
||||
@ -24,7 +24,6 @@ class P2P(ABC):
|
||||
self.nodes = []
|
||||
self.measurement = Measurement(env, config)
|
||||
self.adversary = Adversary(env, config)
|
||||
self.broadcasters = Counter()
|
||||
|
||||
def set_nodes(self, nodes: list["Node"]):
|
||||
self.nodes = nodes
|
||||
@ -40,7 +39,6 @@ class P2P(ABC):
|
||||
# Yield 0 to ensure that the broadcast is done in the same time step.
|
||||
# Without any yield, SimPy complains that the broadcast func is not a generator.
|
||||
yield self.env.timeout(0)
|
||||
self.broadcasters[sender] += 1
|
||||
|
||||
def send(self, msg: SphinxPacket | bytes, hops_traveled: int, sender: "Node", receiver: "Node",
|
||||
is_first_of_broadcasting: bool):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user