[or-cvs] [metrics-web/master 2/2] Add graph on bidirectional connection usage.

karsten at torproject.org karsten at torproject.org
Thu Dec 16 19:51:36 UTC 2010


Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Thu, 16 Dec 2010 20:37:54 +0100
Subject: Add graph on bidirectional connection usage.
Commit: 8d80036dc72e5208effea273494892be1af1ec68

---
 etc/web.xml                                        |    4 ++
 rserve/csv.R                                       |   14 ++++++++
 rserve/graphs.R                                    |   27 +++++++++++++++
 src/org/torproject/ernie/web/CsvServlet.java       |    1 +
 .../ernie/web/GraphParameterChecker.java           |    1 +
 web/WEB-INF/index.jsp                              |    3 ++
 web/WEB-INF/performance.jsp                        |   36 +++++++++++++++++++-
 7 files changed, 85 insertions(+), 1 deletions(-)

diff --git a/etc/web.xml b/etc/web.xml
index 0192fb0..3d96869 100644
--- a/etc/web.xml
+++ b/etc/web.xml
@@ -217,6 +217,10 @@
   </servlet-mapping>
   <servlet-mapping>
     <servlet-name>GraphImage</servlet-name>
+    <url-pattern>/connbidirect.png</url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+    <servlet-name>GraphImage</servlet-name>
     <url-pattern>/routerdetail.png</url-pattern>
   </servlet-mapping>
 
diff --git a/rserve/csv.R b/rserve/csv.R
index 3df0561..c0045c9 100644
--- a/rserve/csv.R
+++ b/rserve/csv.R
@@ -239,3 +239,17 @@ export_monthly_users_average <- function(path) {
   help_export_monthly_users(path, mean)
 }
 
+export_connbidirect <- function(path) {
+  drv <- dbDriver("PostgreSQL")
+  con <- dbConnect(drv, user = dbuser, password = dbpassword, dbname = db)
+  q <- paste("SELECT DATE(statsend) AS date, source, belownum AS below,",
+      "readnum AS read, writenum AS write, bothnum AS \"both\"",
+      "FROM connbidirect ORDER BY 1, 2")
+  rs <- dbSendQuery(con, q)
+  c <- fetch(rs, n = -1)
+  dbDisconnect(con)
+  dbUnloadDriver(drv)
+  write.csv(format(c, trim = TRUE, scientific = FALSE), path, 
+      quote = FALSE, row.names = FALSE)
+}
+
diff --git a/rserve/graphs.R b/rserve/graphs.R
index ee74b0f..9da1731 100644
--- a/rserve/graphs.R
+++ b/rserve/graphs.R
@@ -373,6 +373,33 @@ plot_torperf <- function(start, end, source, filesize, path) {
   ggsave(filename = path, width = 8, height = 5, dpi = 72)
 }
 
+plot_connbidirect <- function(start, end, path) {
+  drv <- dbDriver("PostgreSQL")
+  con <- dbConnect(drv, user = dbuser, password = dbpassword, dbname = db)
+  q <- paste("SELECT DATE(statsend) AS date, readnum, writenum, bothnum ",
+      "FROM connbidirect WHERE DATE(statsend) >= '", start,
+      "' AND DATE(statsend) <= '", end, "'", sep = "")
+  rs <- dbSendQuery(con, q)
+  c <- fetch(rs, n = -1)
+  dbDisconnect(con)
+  dbUnloadDriver(drv)
+  connbidirect <- data.frame(date = c$date, c[, 2:4] /
+      (c$readnum + c$writenum + c$bothnum))
+  connbidirect <- melt(connbidirect, id = "date")
+  ggplot(connbidirect, aes(x = as.Date(date, "%Y-%m-%d"), y = value,
+      colour = variable)) +
+    geom_point(size = 2.5) +
+    scale_x_date(name = paste("\nThe Tor Project - ",
+        "https://metrics.torproject.org/", sep = "")) +
+    scale_y_continuous(name = "", formatter = "percent") +
+    scale_colour_hue("", breaks = c("readnum", "writenum", "bothnum"),
+        labels = c("Mostly reading", "Mostly writing",
+        "Both reading and writing")) +
+    opts(title = "Fraction of connections used uni-/bidirectionally",
+        legend.position = "top")
+  ggsave(filename = path, width = 8, height = 5, dpi = 72)
+}
+
 ## TODO The bandwidth history shouldn't be based on the consensus weights
 ## which aren't bandwidths anymore, but either on the advertised bandwidth
 ## contained in server descriptors or better on the bandwidth history
diff --git a/src/org/torproject/ernie/web/CsvServlet.java b/src/org/torproject/ernie/web/CsvServlet.java
index 0c285e5..9c3ead4 100644
--- a/src/org/torproject/ernie/web/CsvServlet.java
+++ b/src/org/torproject/ernie/web/CsvServlet.java
@@ -31,6 +31,7 @@ public class CsvServlet extends HttpServlet {
     this.availableCsvFiles = new HashSet<String>();
     this.availableCsvFiles.add("bandwidth");
     this.availableCsvFiles.add("bridge-users");
+    this.availableCsvFiles.add("connbidirect");
     this.availableCsvFiles.add("current-platform-strings");
     this.availableCsvFiles.add("direct-users");
     this.availableCsvFiles.add("dirbytes");
diff --git a/src/org/torproject/ernie/web/GraphParameterChecker.java b/src/org/torproject/ernie/web/GraphParameterChecker.java
index 67d9706..b1e31d7 100644
--- a/src/org/torproject/ernie/web/GraphParameterChecker.java
+++ b/src/org/torproject/ernie/web/GraphParameterChecker.java
@@ -55,6 +55,7 @@ public class GraphParameterChecker {
     this.availableGraphs.put("gettor", "start,end,bundle,filename");
     this.availableGraphs.put("torperf",
          "start,end,source,filesize,filename");
+    this.availableGraphs.put("connbidirect", "start,end,filename");
     this.availableGraphs.put("routerdetail", "fingerprint,filename");
 
     this.knownParameterValues = new HashMap<String, String>();
diff --git a/web/WEB-INF/index.jsp b/web/WEB-INF/index.jsp
index deb9f18..8d1bbe9 100644
--- a/web/WEB-INF/index.jsp
+++ b/web/WEB-INF/index.jsp
@@ -32,6 +32,9 @@
         <br>
         <h3>News</h3>
         <ul>
+          <li>December 16, 2010: Graph and raw data on
+          <a href="performance.html">Fraction of connections used
+          uni-/bidirectionally</a> is available.</li>
           <li>November 30, 2010: Tech report on
           <a href="papers/countingusers-2010-11-30.pdf">Privacy-preserving
           Ways to Estimate the Number of Tor Users</a> is available for
diff --git a/web/WEB-INF/performance.jsp b/web/WEB-INF/performance.jsp
index adcf126..06bf422 100644
--- a/web/WEB-INF/performance.jsp
+++ b/web/WEB-INF/performance.jsp
@@ -47,9 +47,43 @@ quartile of request times.</p>
     </p>
   </div>
 </form>
-
 <p><a href="csv/torperf.csv">CSV</a> file containing all data.</p>
+
+<br>
+<h3>Fraction of connections used uni-/bidirectionally</h3>
+<br>
+<p>The following graph shows the fraction of connections that is used
+uni- or bi-directionally.  Every 10 seconds, relays determine for every
+connection whether they read and wrote less more a threshold of 20 KiB.
+Connections below this threshold are excluded from these statistics.  For
+the remaining connections, relays report whether they read/wrote at least
+10 times as many bytes as they wrote/read.  If so, they classify a
+connection as "Mostly reading" or "Mostly writing," respectively.  All
+other connections are classified as "Both reading and writing."  After
+classifying connections, read and write counters are reset for the next
+10-second interval.  Statistics are aggregated over 24 hours.</p>
+<a name="connbidirect"></a>
+<img src="connbidirect.png${connbidirect_url}"
+     width="576" height="360"
+     alt="Fraction of direct connections used uni-/bidirectionally">
+<form action="performance.html#connbidirect">
+  <div class="formrow">
+    <input type="hidden" name="graph" value="connbidirect">
+    <p>
+    <label>Start date (yyyy-mm-dd):</label>
+      <input type="text" name="start" size="10"
+             value="${connbidirect_start[0]}">
+    <label>End date (yyyy-mm-dd):</label>
+      <input type="text" name="end" size="10"
+             value="${connbidirect_end[0]}">
+    </p><p>
+    <input class="submit" type="submit" value="Update graph">
+    </p>
+  </div>
+</form>
+<p><a href="csv/connbidirect.csv">CSV</a> file containing all data.</p>
 <br>
+
     </div>
   </div>
   <div class="bottom" id="bottom">
-- 
1.7.1



More information about the tor-commits mailing list