add hue and legend. update readme
This commit is contained in:
parent
30a82265c9
commit
908fd86190
|
@ -50,6 +50,9 @@ For more details, please see the [Time and Scheduling](https://simpy.readthedocs
|
|||
## [Adversary Models](https://www.notion.so/Mixnet-v2-Proof-of-Concept-102d0563e75345a3a6f1c11791fbd746?pvs=4#c5ffa49486ce47ed81d25028bc0d9d40)
|
||||
- [x] Identifying nodes emitting messages around the promised interval.
|
||||
- [ ] With partial visibility
|
||||
- [ ] Quantifying how much the expected frequent senders are anonymized
|
||||
- Current output
|
||||
![](./docs/msgs-around-interval.png)
|
||||
- [ ] Correlating senders-receivers based on timing
|
||||
- [ ] Active attacks
|
||||
- [ ] Reporting & Visualization
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 52 KiB |
|
@ -21,12 +21,17 @@ if __name__ == "__main__":
|
|||
print(df.describe())
|
||||
|
||||
# Visualize the nodes emitted messages around the promised interval
|
||||
df = pd.DataFrame([(node.id, cnt) for node, cnt in sim.p2p.nodes_emitted_msg_around_interval.items()], columns=["node", "count"])
|
||||
df = pd.DataFrame(
|
||||
[(node.id, cnt, node.id < len(config.real_message_prob_weights))
|
||||
for node, cnt in sim.p2p.senders_around_interval.items()],
|
||||
columns=["NodeID", "Count", "Expected"]
|
||||
)
|
||||
plt.figure(figsize=(10, 6))
|
||||
seaborn.barplot(x="node", y="count", data=df)
|
||||
seaborn.barplot(data=df, x="NodeID", y="Count", hue="Expected", palette={True: "red", False: "blue"})
|
||||
plt.title("Messages emitted around the promised interval")
|
||||
plt.xlabel("Node ID")
|
||||
plt.xlabel("Sender Node ID")
|
||||
plt.ylabel("Msg Count")
|
||||
plt.legend(title="Expected")
|
||||
plt.show()
|
||||
|
||||
print("Simulation complete!")
|
|
@ -14,7 +14,7 @@ class P2p:
|
|||
self.config = config
|
||||
self.nodes = []
|
||||
self.message_sizes = []
|
||||
self.nodes_emitted_msg_around_interval = defaultdict(int)
|
||||
self.senders_around_interval = defaultdict(int)
|
||||
|
||||
def add_node(self, nodes):
|
||||
self.nodes.extend(nodes)
|
||||
|
@ -26,7 +26,7 @@ class P2p:
|
|||
|
||||
now_frac, now_int = math.modf(self.env.now)
|
||||
if now_int % self.config.message_interval == 0 and now_frac <= self.config.max_message_prep_time:
|
||||
self.nodes_emitted_msg_around_interval[sender] += 1
|
||||
self.senders_around_interval[sender] += 1
|
||||
|
||||
# Yield 0 to ensure that the broadcast is done in the same time step.
|
||||
# Without this, SimPy complains that the broadcast func is not a generator.
|
||||
|
|
Loading…
Reference in New Issue