diff --git a/mixnet/v2/sim/README.md b/mixnet/v2/sim/README.md index f8cbadc..e4382f6 100644 --- a/mixnet/v2/sim/README.md +++ b/mixnet/v2/sim/README.md @@ -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 diff --git a/mixnet/v2/sim/docs/msgs-around-interval.png b/mixnet/v2/sim/docs/msgs-around-interval.png new file mode 100644 index 0000000..f5fc292 Binary files /dev/null and b/mixnet/v2/sim/docs/msgs-around-interval.png differ diff --git a/mixnet/v2/sim/main.py b/mixnet/v2/sim/main.py index 6a1037f..a5ded12 100644 --- a/mixnet/v2/sim/main.py +++ b/mixnet/v2/sim/main.py @@ -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!") \ No newline at end of file diff --git a/mixnet/v2/sim/p2p.py b/mixnet/v2/sim/p2p.py index 733e577..0bd5a8e 100644 --- a/mixnet/v2/sim/p2p.py +++ b/mixnet/v2/sim/p2p.py @@ -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.