commit 31f7b2a72901f7484f72e87e8013f15d89f28992 Author: Karsten Loesing karsten.loesing@gmx.net Date: Sun Jan 15 06:10:23 2012 +0100
Add graphing code for #4906. --- task-4906/.gitignore | 7 +++++++ task-4906/Eval.java | 44 ++++++++++++++++++++++++++++++++++++++++++++ task-4906/README | 19 +++++++++++++++++++ task-4906/eval.R | 22 ++++++++++++++++++++++ 4 files changed, 92 insertions(+), 0 deletions(-)
diff --git a/task-4906/.gitignore b/task-4906/.gitignore new file mode 100644 index 0000000..515a3f8 --- /dev/null +++ b/task-4906/.gitignore @@ -0,0 +1,7 @@ +*.class +in/ +lib/ +Rplots.pdf +out.csv +*.png + diff --git a/task-4906/Eval.java b/task-4906/Eval.java new file mode 100644 index 0000000..1d2d702 --- /dev/null +++ b/task-4906/Eval.java @@ -0,0 +1,44 @@ +import java.io.*; +import java.util.*; +import org.torproject.descriptor.*; + +public class Eval { + public static void main(String[] args) throws IOException { + SortedMap<String, String> lines = new TreeMap<String, String>(); + File inputDirectory = new File("in"); + RelayDescriptorReader reader = + DescriptorSourceFactory.createRelayDescriptorReader(); + reader.addDirectory(inputDirectory); + Iterator<DescriptorFile> descriptorFiles = reader.readDescriptors(); + while (descriptorFiles.hasNext()) { + DescriptorFile descriptorFile = descriptorFiles.next(); + for (Descriptor descriptor : descriptorFile.getDescriptors()) { + if (!(descriptor instanceof ExtraInfoDescriptor)) { + continue; + } + ExtraInfoDescriptor extraInfoDescriptor = + (ExtraInfoDescriptor) descriptor; + BandwidthHistory dirreqWriteHistory = + extraInfoDescriptor.getDirreqWriteHistory(); + if (dirreqWriteHistory != null) { + String nickname = extraInfoDescriptor.getNickname(); + for (Map.Entry<Long, Long> e : + dirreqWriteHistory.getBandwidthValues().entrySet()) { + long intervalEnd = e.getKey(); + long writtenDirreqBytes = e.getValue(); + String key = nickname + "," + + String.valueOf(intervalEnd / 1000L); + String value = key + "," + String.valueOf(writtenDirreqBytes); + lines.put(key, value); + } + } + } + } + BufferedWriter bw = new BufferedWriter(new FileWriter("out.csv")); + for (String line : lines.values()) { + bw.write(line + "\n"); + } + bw.close(); + } +} + diff --git a/task-4906/README b/task-4906/README new file mode 100644 index 0000000..7b1f97f --- /dev/null +++ b/task-4906/README @@ -0,0 +1,19 @@ +Download and extract extra-info descriptors published by the directory +authorities. Put them in an in/ subdirectory. + + $ grep -REil "^extra-info gabelmoo|^extra-info moria1|^extra-info tor26| + ^extra-info ides|^extra-info dannenberg|^extra-info urras| + ^extra-info maatuska|^extra-info dizum" extra-infos-20??-?? | + xargs -I{} mv {} in/ + +Put metrics-lib's descriptor.jar in lib/. + +Run the Java program. + + $ javac -cp lib/descriptor.jar Eval.java + $ java -cp .:lib/descriptor.jar Eval + +Run R. + + $ R --slave -f eval.R + diff --git a/task-4906/eval.R b/task-4906/eval.R new file mode 100644 index 0000000..393fb7e --- /dev/null +++ b/task-4906/eval.R @@ -0,0 +1,22 @@ +library(ggplot2) +d <- read.csv("out.csv", header = FALSE, + col.names = c("dirauth", "intervalend", "writtendirreqbytes")) +d <- data.frame(dirauth = d$dirauth, + date = as.Date(d$intervalend / 86400, origin = "1970-01-01 00:00:00"), + writtendirreqbytes = d$writtendirreqbytes, count = 1) +c <- aggregate(x = list(count = d$count), + by = list(dirauth = d$dirauth, date = d$date), FUN = sum) +d <- aggregate(x = list(writtendirreqbytes = d$writtendirreqbytes), + by = list(dirauth = d$dirauth, date = d$date), FUN = sum) +e <- data.frame(dirauth = d$dirauth, date = d$date, + writtendirreqbytespersec = (d$writtendirreqbytes / c$count) / 900) +ggplot(e, aes(x = date, y = writtendirreqbytespersec / 1024, + colour = dirauth)) + +geom_line() + +scale_x_date(name = "\nDate") + +scale_y_continuous(name = "KiB/s\n") + +scale_colour_hue(name = "Directory authority") + +opts(title = "Written bytes on CONN_TYPE_DIR connections\n") +ggsave("dirauth-written-dirreq-bytes.png", width = 8, height = 6, + dpi = 100) +