Commit fe1906ec authored by Karsten Loesing's avatar Karsten Loesing
Browse files

Add sources for buildtimes report.

parent 61fc0865
Loading
Loading
Loading
Loading
+119 −0
Original line number Diff line number Diff line
### Copyright 2007 Steven J. Murdoch, 2009 Karsten Loesing
### See LICENSE for licensing information

UFACTOR = 1e6

## Subtract to timevals, maintaining precision
todelta <- function(startsec, startusec, tsec, tusec) {
  tsec[tsec == 0] <- NA
  dsec <- tsec - startsec
  dusec <- tusec - startusec
  return(dsec*UFACTOR + dusec)
}

parsedata <- function(filename) {

  t = read.table(filename, header=TRUE)

  ## Make sure that the table has column names
  if (is.null(t$startsec)) {
    t <- read.table(filename, col.names=c("startsec", "startusec",
      "socketsec", "socketusec", "connectsec", "connectusec",
      "negotiatesec", "negotiateusec", "requestsec", "requestusec",
      "responsesec", "responseusec", "datarequestsec", "datarequestusec",
      "dataresponsesec", "dataresponseusec", "datacompletesec",
      "datacompleteusec", "writebytes", "readbytes"))
  }

  tStart <- t$startsec*UFACTOR + t$startusec
  dSocket <- todelta(t$startsec, t$startusec, t$socketsec, t$socketusec)
  dConnect <- todelta(t$startsec, t$startusec, t$connectsec, t$connectusec)
  dNegotiate <- todelta(t$startsec, t$startusec, t$negotiatesec, t$negotiateusec)
  dRequest <- todelta(t$startsec, t$startusec, t$requestsec, t$requestusec)
  dResponse <- todelta(t$startsec, t$startusec, t$responsesec, t$responseusec)
  dDRequest <- todelta(t$startsec, t$startusec, t$datarequestsec, t$datarequestusec)
  dDResponse <- todelta(t$startsec, t$startusec, t$dataresponsesec, t$dataresponseusec)
  dDComplete <- todelta(t$startsec, t$startusec, t$datacompletesec, t$datacompleteusec)
  cbWrite <- t$writebytes
  cbRead <- t$readbytes
  
  results <- data.frame(tStart, dSocket, dConnect,
                        dNegotiate, dRequest, dResponse,
                        dDRequest, dDResponse, dDComplete,
                        cbWrite, cbRead)

  invalid <- t$datacompletesec == 0
  results[invalid,] <- NA
  invalid <- t$dataresponsesec == 0
  results[invalid,] <- NA

  return(results)
}

plotboxes <- function(e1, e2, labels, title, ylim=c(NA,NA)) {
  range <- 1.5
  MinY <- ylim[1]
  MaxY <- ylim[2]
  ## Find how many points this will cause to be skipped
  skipped <- c()
  labels[1] <- paste(labels[1], " (", length(na.omit(e1)), ", ", length(e1) - length(na.omit(e1)), ", ", length(e1[e1 > MaxY]), ")", sep="")
  labels[2] <- paste(labels[2], " (", length(na.omit(e2)), ", ", length(e2) - length(na.omit(e2)), ", ", length(e2[e2 > MaxY]), ")", sep="")
  e1[e1 > MaxY] <- NA
  e2[e2 > MaxY] <- NA

  ## Plot the data
  boxplot(e1, e2, frame.plot=FALSE, axes=FALSE, ylab="Time (s)", range=range,
          ylim=c(MinY, MaxY), xlab="Configuration size (# runs, # timeouts, # points omitted)", main="",
          pars=list(show.names=TRUE, boxwex = 0.8, staplewex = 0.5, outwex = 0.5))
  axis(1, at=1:length(labels), labels=labels, lwd=0)
  axis(2, las=1)
}

plotdensity <- function(data1, data2, title, maxX, dens) {
if (dens == 1) {
  plot(density(na.omit(data1/1e6)), col="red", axes=FALSE, xlim=c(0,maxX), main=title, xlab="Time [s]")
  lines(density(na.omit(data2/1e6)), col="blue")
} else {
  plot(density(na.omit(data2/1e6)), col="blue", axes=FALSE, xlim=c(0,maxX), main=title, xlab="Time [s]")
  lines(density(na.omit(data1/1e6)), col="red")
}
median1 <- median(data1/1e6, na.rm=TRUE)
median2 <- median(data2/1e6, na.rm=TRUE)
abline(v=median1, col="red", lty=2)
abline(v=median2, col="blue", lty=2)
adj1 <- 0
adj2 <- 1
if (median1 < median2) {
  adj1 <- 1
  adj2 <- 0
}
mtext(paste("md =", format(median1, digits=3)), side=3, at=median1, col="red", adj=adj1)
mtext(paste("md =", format(median2, digits=3)), side=3, at=median2, col="blue", adj=adj2)
axis(1, lwd.ticks=1, lwd=0)
axis(1, at=c(0, maxX*65/60), labels=FALSE, lwd.ticks=0)
legend(x=maxX, xjust=1, y=par("usr")[4], fill=c("blue", "red"), ncol=1, legend=c("build-time patch", "unpatched"), bty="n")
}

plotdensities <- function(filename, data1m, data2m, maxm, densm, data1g, data2g, maxg, densg, title) {
pdf(filename, width=8, height=6)
par(mfrow=c(2, 1))
par(mar=c(4.3,0.1,3.6,0.1))

plotdensity(data1m, data2m, paste(title, "(50 KiB, moria)"), maxm, densm)
plotdensity(data1g, data2g, paste(title, "(50 KiB, gabelmoo)"), maxg, densg)

dev.off()
}

m_orig <- parsedata("moria-50kb.data")
m_circ <- parsedata("moria-mike50kb.data")
median(na.omit(m_circ[,6]))
g_orig <- parsedata("gabelmoo-50kb.data")
g_circ <- parsedata("gabelmoo-mike50kb.data")
m_orig <- subset(m_orig, tStart >= m_circ$tStart[1])
g_orig <- subset(g_orig, tStart >= g_circ$tStart[1])

plotdensities("connected.pdf", m_orig[,6], m_circ[,6], 5, 2, g_orig[,6], g_circ[,6], 5, 2, "Time to connect to website")
plotdensities("firstbyte.pdf", m_orig[,8], m_circ[,8], 15, 2, g_orig[,8], g_circ[,8], 15, 2, "Time until receiving first response byte")
plotdensities("download.pdf", m_orig[,9], m_circ[,9], 30, 2, g_orig[,9], g_circ[,9], 30, 2, "Time to complete request")
+59 −0
Original line number Diff line number Diff line
\documentclass{article}
\usepackage{url}
\usepackage[dvips]{graphicx}
\usepackage{graphics}
\usepackage{color}
\begin{document}
\title{Dynamically Adjusting Circuit Build Timeouts}
\author{Karsten Loesing}
\maketitle

\section{Introduction}

Current Tor clients use a fixed timeout when deciding whether to give up on
building a circuit or not.
In this experiment, Tor clients adapt their circuit build timeout from
observations of previously successful circuit build times.

\section{Results}

The first measured time is the time to
connect to the website. This step requires the Tor client to create a
circuit using the specified exit and send a \texttt{CONNECT} command to the
exit relay. As soon as the exit relay replies with a \texttt{CONNECTED}
cell, the connection to the website is established.
Figure~\ref{fig:connected} shows kernel density estimates of the connection
times.

\begin{figure}
\centering
\includegraphics[width=.85\textwidth]{connected.pdf}
\caption{Kernel density estimates of times to connect to website}
\label{fig:connected}
\end{figure}

The second measured time is the time between starting a request and
receiving the first byte of the response. Figure~\ref{fig:firstbyte} shows
these times for the three requested file sizes.

\begin{figure}
\centering
\includegraphics[width=.85\textwidth]{firstbyte.pdf}
\caption{Kernel density estimates of times until receiving first response byte}
\label{fig:firstbyte}
\end{figure}

The third measured time is the overall time to complete a request. This
time include all steps from connecting to the website until having received
all bytes of the response. Figure~\ref{fig:download} shows the
distributions of these times.

\begin{figure}
\centering
\includegraphics[width=.85\textwidth]{download.pdf}
\caption{Kernel density estimates of times to complete request}
\label{fig:download}
\end{figure}

\end{document}
+8.22 KiB

File added.

No diff preview for this file type.

+11.6 KiB

File added.

Preview size limit exceeded, changes collapsed.

+11.1 KiB

File added.

Preview size limit exceeded, changes collapsed.

Loading