[tor-commits] [metrics-tasks/master] Add graphing code for #1854.

karsten at torproject.org karsten at torproject.org
Wed Sep 19 00:07:09 UTC 2012


commit 2ed7526d2b22b66dfebd035baaeb47f1cb94657a
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Tue Sep 18 19:45:37 2012 -0400

    Add graphing code for #1854.
---
 task-1854/.gitignore     |    2 +
 task-1854/plot-entropy.R |   53 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/task-1854/.gitignore b/task-1854/.gitignore
index ada3ff3..f6115f4 100644
--- a/task-1854/.gitignore
+++ b/task-1854/.gitignore
@@ -4,4 +4,6 @@ entropy.csv
 in/
 pygeoip/
 stem/
+Rplots.pdf
+*.png
 
diff --git a/task-1854/plot-entropy.R b/task-1854/plot-entropy.R
new file mode 100644
index 0000000..e28193f
--- /dev/null
+++ b/task-1854/plot-entropy.R
@@ -0,0 +1,53 @@
+library(ggplot2)
+library(reshape)
+library(scales)
+
+d <- read.csv("entropy.csv", header = FALSE,
+  col.names = c("validafter", "min_cw", "relays", "all", "max_all",
+  "exit", "max_exit", "guard", "max_guard", "country", "max_country",
+  "as", "max_as"), stringsAsFactor = FALSE)
+max_validafter <- max(d$validafter)
+d <- d[d$validafter == max_validafter, ]
+
+e <- d[d$min_cw <= 10000, ]
+e <- data.frame(min_cw = e$min_cw, all = e$all / e$max_all,
+  exit = e$exit / e$max_exit, guard = e$guard / e$max_guard,
+  country = e$country / e$max_country, as = e$as / e$max_as)
+e <- melt(e, "min_cw")
+e <- data.frame(min_cw = e$min_cw, variable =
+  ifelse(e$variable == "all", "All relays",
+  ifelse(e$variable == "exit", "All exits",
+  ifelse(e$variable == "guard", "All guards",
+  ifelse(e$variable == "country", "All countries",
+  "All ASes")))), value = e$value)
+ggplot(e, aes(x = min_cw, y = value)) +
+geom_line() +
+facet_wrap(~ variable) +
+scale_x_continuous(name = "\nMinimum consensus weight") +
+scale_y_continuous(name = "", limits = c(0, 1), labels = percent) +
+opts(title = paste("Degree of anonymity based on consensus from ",
+  max_validafter, "\n", sep = ""))
+ggsave("degree-of-anonymity-min-cw.png", width = 8, height = 6, dpi = 100)
+
+f <- d[d$min_cw <= 10000, ]
+f <- rbind(
+  data.frame(min_cw = f$min_cw, entropy = f$all, max = f$max_all,
+    type = "All relays"),
+  data.frame(min_cw = f$min_cw, entropy = f$exit, max = f$max_exit,
+    type = "All exits"),
+  data.frame(min_cw = f$min_cw, entropy = f$guard, max = f$max_guard,
+    type = "All guards"),
+  data.frame(min_cw = f$min_cw, entropy = f$country, max = f$max_country,
+    type = "All countries"),
+  data.frame(min_cw = f$min_cw, entropy = f$as, max = f$max_as,
+    type = "All ASes"))
+f <- melt(f, c("min_cw", "type"))
+ggplot(f, aes(x = min_cw, y = value, colour = variable)) +
+geom_line() +
+facet_wrap(~ type) +
+scale_x_continuous(name = "\nMinimum consensus weight") +
+scale_y_continuous(name = "", limits = c(0, max(f$value))) +
+opts(title = paste("Entropy and maximum entropy based on consensus from ",
+  max_validafter, "\n", sep = ""), legend.position = "none")
+ggsave("entropy-min-cw.png", width = 8, height = 6, dpi = 100)
+



More information about the tor-commits mailing list