Last active
February 14, 2017 16:56
-
-
Save antitree/5def23b7f6b12d466e38bf749bcb248f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
load_trace <- function(filename, nickname, proto, n) { | |
x <- read.csv(filename) | |
x$ts <- x$ts - min(x$ts) | |
x$sz <- x$size * ifelse(x$dir=="up", 1, -1) | |
data.frame(x, nickname=nickname, proto=proto, n=n) | |
} | |
# derive nickname, proto, and n columns from the filename. | |
load_trace_magic_filename <- function(filename) { | |
m <- regexec("^traces/(.*)-(.*)/trace(.*)\\.pcap\\.csv$", filename) | |
if (m[[1]][[1]] == -1) { | |
stop(sprintf("weird filename %s", filename)) | |
} | |
v <- regmatches(filename, m)[[1]] | |
load_trace(filename, nickname=v[[2]], proto=v[[3]], n=as.integer(v[[4]])) | |
} | |
x <- data.frame() | |
for (filename in Sys.glob("traces/*/trace*.pcap.csv")) { | |
cat(sprintf("%s\n", filename)) | |
x <- rbind(x, load_trace_magic_filename(filename)) | |
} | |
make_graph <- function(x) { | |
x <- x[x$n < 3, ] | |
p <- ggplot(x, aes(x=ts, y=sz, ymin=0, ymax=sz, color=dir)) | |
p <- p + geom_linerange(size=0.5, alpha=0.9) | |
#p <- p + geom_point(aes(size=psh)) | |
p <- p + scale_x_continuous(breaks=0:6, minor_breaks=NULL) | |
p <- p + scale_y_continuous(breaks=c(-1500, -1000, -500, 0, 500, 1000, 1500), minor_breaks=NULL, labels=function(x){abs(x)}) | |
p <- p + scale_size_manual(values=c("FALSE"=0, "TRUE"=2)) | |
p <- p + scale_color_manual(breaks=c("up", "down"), values=c(up="goldenrod", down="darkviolet"), guide=F) | |
p <- p + coord_cartesian(xlim=c(0, 6.0), ylim=c(min(x$sz, -1540), max(x$sz, 1540))) | |
p <- p + facet_grid(nickname+proto+sprintf("#%d", n) ~ .) | |
p <- p + guides(guide_legend(override.aes=list(shape=16, size=5, alpha=1))) | |
p <- p + labs(x="time (seconds)", y="segment size") | |
p <- p + theme_minimal() | |
p <- p + theme(panel.grid=element_line(size=0.1)) | |
p <- p + theme(axis.text.y=element_text(size=8)) | |
p | |
} | |
#p <- make_graph(x) | |
#ggsave("graph/all.pdf", p, width=7, height=18) | |
p <- make_graph(x[x$nickname == "inky" & x$proto == "plain", ]) | |
p <- p + ggtitle("default vanilla") | |
ggsave("graph/timing-inky-or.png", p, width=7, height=3, dpi=100) | |
#p <- make_graph(x[x$nickname == "eRYaZuvY02FpExln", ]) | |
#p <- p + ggtitle("non-default vanilla") | |
#ggsave("graph/timing-eRYaZuvY02FpExln-or.png", p, width=7, height=3, dpi=100) | |
#p <- make_graph(x[x$nickname == "riemann", ]) | |
#p <- p + ggtitle("riemann obfs4 iat-mode=0") | |
#ggsave("graph/timing-riemann-obfs4iat0.png", p, width=7, height=3, dpi=100) | |
#p <- make_graph(x[x$nickname == "unused" & x$proto == "obfs4iat0", ]) | |
#p <- p + ggtitle("non-default obfs4 iat-mode=0") | |
#ggsave("graph/timing-unused-obfs4iat0.png", p, width=7, height=3, dpi=100) | |
#p <- make_graph(x[x$nickname == "ndnop3", ]) | |
#p <- p + ggtitle("ndnop3 obfs4 iat-mode=1") | |
#ggsave("graph/timing-ndnop3-obfs4iat1.png", p, width=7, height=3, dpi=100) | |
#p <- make_graph(x[x$nickname == "unused" & x$proto == "obfs4iat1", ]) | |
#p <- p + ggtitle("non-default obfs4 iat-mode=1") | |
#ggsave("graph/timing-unused-obfs4iat1.png", p, width=7, height=3, dpi=100) | |
#p <- make_graph(x[x$nickname == "ndnop5", ]) | |
#p <- p + ggtitle("ndnop5 obfs4 iat-mode=2") | |
#ggsave("graph/timing-ndnop5-obfs4iat2.png", p, width=7, height=3, dpi=100) | |
#p <- make_graph(x[x$nickname == "unused" & x$proto == "obfs4iat2", ]) | |
#p <- p + ggtitle("non-default obfs4 iat-mode=2") | |
#ggsave("graph/timing-unused-obfs4iat2.png", p, width=7, height=3, dpi=100) | |
#p <- make_graph(x[x$nickname == "Lisbeth", ]) | |
#p <- p + ggtitle("Lisbeth obfs4 iat-mode=0") | |
#ggsave("graph/timing-Lisbeth-obfs4iat0.png", p, width=7, height=3, dpi=100) | |
#p <- make_graph(x[x$nickname == "unused" & x$proto == "obfs4cypherpunkkludge", ]) | |
#p <- p + ggtitle("non-default obfs4 iat-mode=0 with comment:61 kludge") | |
#ggsave("graph/timing-unused-obfs4cypherpunkkludge.png", p, width=7, height=3, dpi=100) | |
#p <- make_graph(x[x$nickname == "unused" & x$proto == "obfs4timekludge", ]) | |
#p <- p + ggtitle("non-default obfs4 iat-mode=0 with timekludge") | |
#ggsave("graph/timing-unused-obfs4timekludge.png", p, width=7, height=3, dpi=100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment