Loading HOWTO +2 −1 Original line number Diff line number Diff line Loading @@ -112,7 +112,8 @@ The following evaluations are available: 3. Observed bandwidth vs. {read|write}history 4. Relays on dynamic IP addresses 5. Relays by country 6. Relay bandwidth by country 6. Advertised bandwidth by country 7. Bandwidth history by country Every evaluation (besides the sanity check) writes a single output file to the out/dirarch/ directory. These output files are comma-separated-value Loading src/org/torproject/metrics/dirarch/EvaluateDirectoryData.java +92 −2 Original line number Diff line number Diff line Loading @@ -521,9 +521,9 @@ public final class EvaluateDirectoryData { - started) / 1000) + " seconds."); } // how much bandwidth do routers advertise per country? // how much bandwidth do routers report in their histories per country? if (evaluation == -1 || evaluation == 6) { System.out.print("Summing up advertised bandwidth claims per " System.out.print("Summing up bandwidth histories per " + "country... "); long started = System.currentTimeMillis(); rs = s.executeQuery("SELECT country FROM descriptor " Loading Loading @@ -636,6 +636,96 @@ public final class EvaluateDirectoryData { - started) / 1000) + " seconds."); } // how much bandwidth do routers advertise per country? if (evaluation == -1 || evaluation == 7) { System.out.print("Summing up advertised bandwidth claims per " + "country... "); long started = System.currentTimeMillis(); rs = s.executeQuery("SELECT country FROM descriptor " + "GROUP BY country"); SortedSet<String> countries = new TreeSet<String>(); while (rs.next()) { countries.add(rs.getString("country")); } File file = new File(outputDirectory.getAbsolutePath() + File.separatorChar + "countryadvbw.csv"); out = new BufferedWriter(new FileWriter(file, false)); out.write("time,"); for (String f : countries) { out.write("a" + f + ",b" + f + ",o" + f + ","); } out.write("atotal,btotal,ototal\n"); rs = s.executeQuery("SELECT DATE(validafter), country, " + "SUM(bandwidthavg) AS average, " + "SUM(bandwidthburst) AS burst, " + "SUM(bandwidthobserved) AS observed " + "FROM statusentry NATURAL JOIN descriptor " + "WHERE running = '1' GROUP BY DATE(validafter), country " + "ORDER BY DATE(validafter)"); String date = null; Map<String, Double[]> nodesSeen = new HashMap<String, Double[]>(); while (rs.next()) { if (date != null && !rs.getString("date").equals(date)) { out.write(date); double c = (double) consensusesPerDay.get(date); double[] total = new double[3]; for (String f : countries) { if (nodesSeen.containsKey(f)) { Double[] vals = nodesSeen.get(f); for (int i = 0; i < 3; i++) { out.write("," + (int) (vals[i].doubleValue() / c)); total[i] += vals[i].doubleValue(); } } else { out.write(",0,0,0"); } } for (int i = 0; i < 3; i++) { out.write("," + ((int) (total[i] / c))); } out.write("\n"); nodesSeen.clear(); if (date.equals("2008-10-24")) { // terrible hack!!! out.write("2008-10-25"); for (int i = 0; i < countries.size(); i++) { out.write(",NA,NA,NA"); } out.write(",NA,NA,NA\n"); } } date = rs.getString("date"); Double[] vals = new Double[3]; vals[0] = rs.getDouble("average"); vals[1] = rs.getDouble("burst"); vals[2] = rs.getDouble("observed"); nodesSeen.put(rs.getString("country"), vals); } out.write(date); int c = consensusesPerDay.get(date); double[] total = new double[3]; for (String f : countries) { if (nodesSeen.containsKey(f)) { Double[] vals = nodesSeen.get(f); for (int i = 0; i < 3; i++) { out.write("," + (int) (vals[i].doubleValue() / c)); total[i] += vals[i].doubleValue(); } } else { out.write(",0,0,0"); } } for (int i = 0; i < 3; i++) { out.write("," + ((int) (total[i] / c))); } out.write("\n"); out.close(); rs.close(); System.out.println("finished after " + ((System.currentTimeMillis() - started) / 1000) + " seconds."); } // disconnect from database conn.close(); } Loading Loading
HOWTO +2 −1 Original line number Diff line number Diff line Loading @@ -112,7 +112,8 @@ The following evaluations are available: 3. Observed bandwidth vs. {read|write}history 4. Relays on dynamic IP addresses 5. Relays by country 6. Relay bandwidth by country 6. Advertised bandwidth by country 7. Bandwidth history by country Every evaluation (besides the sanity check) writes a single output file to the out/dirarch/ directory. These output files are comma-separated-value Loading
src/org/torproject/metrics/dirarch/EvaluateDirectoryData.java +92 −2 Original line number Diff line number Diff line Loading @@ -521,9 +521,9 @@ public final class EvaluateDirectoryData { - started) / 1000) + " seconds."); } // how much bandwidth do routers advertise per country? // how much bandwidth do routers report in their histories per country? if (evaluation == -1 || evaluation == 6) { System.out.print("Summing up advertised bandwidth claims per " System.out.print("Summing up bandwidth histories per " + "country... "); long started = System.currentTimeMillis(); rs = s.executeQuery("SELECT country FROM descriptor " Loading Loading @@ -636,6 +636,96 @@ public final class EvaluateDirectoryData { - started) / 1000) + " seconds."); } // how much bandwidth do routers advertise per country? if (evaluation == -1 || evaluation == 7) { System.out.print("Summing up advertised bandwidth claims per " + "country... "); long started = System.currentTimeMillis(); rs = s.executeQuery("SELECT country FROM descriptor " + "GROUP BY country"); SortedSet<String> countries = new TreeSet<String>(); while (rs.next()) { countries.add(rs.getString("country")); } File file = new File(outputDirectory.getAbsolutePath() + File.separatorChar + "countryadvbw.csv"); out = new BufferedWriter(new FileWriter(file, false)); out.write("time,"); for (String f : countries) { out.write("a" + f + ",b" + f + ",o" + f + ","); } out.write("atotal,btotal,ototal\n"); rs = s.executeQuery("SELECT DATE(validafter), country, " + "SUM(bandwidthavg) AS average, " + "SUM(bandwidthburst) AS burst, " + "SUM(bandwidthobserved) AS observed " + "FROM statusentry NATURAL JOIN descriptor " + "WHERE running = '1' GROUP BY DATE(validafter), country " + "ORDER BY DATE(validafter)"); String date = null; Map<String, Double[]> nodesSeen = new HashMap<String, Double[]>(); while (rs.next()) { if (date != null && !rs.getString("date").equals(date)) { out.write(date); double c = (double) consensusesPerDay.get(date); double[] total = new double[3]; for (String f : countries) { if (nodesSeen.containsKey(f)) { Double[] vals = nodesSeen.get(f); for (int i = 0; i < 3; i++) { out.write("," + (int) (vals[i].doubleValue() / c)); total[i] += vals[i].doubleValue(); } } else { out.write(",0,0,0"); } } for (int i = 0; i < 3; i++) { out.write("," + ((int) (total[i] / c))); } out.write("\n"); nodesSeen.clear(); if (date.equals("2008-10-24")) { // terrible hack!!! out.write("2008-10-25"); for (int i = 0; i < countries.size(); i++) { out.write(",NA,NA,NA"); } out.write(",NA,NA,NA\n"); } } date = rs.getString("date"); Double[] vals = new Double[3]; vals[0] = rs.getDouble("average"); vals[1] = rs.getDouble("burst"); vals[2] = rs.getDouble("observed"); nodesSeen.put(rs.getString("country"), vals); } out.write(date); int c = consensusesPerDay.get(date); double[] total = new double[3]; for (String f : countries) { if (nodesSeen.containsKey(f)) { Double[] vals = nodesSeen.get(f); for (int i = 0; i < 3; i++) { out.write("," + (int) (vals[i].doubleValue() / c)); total[i] += vals[i].doubleValue(); } } else { out.write(",0,0,0"); } } for (int i = 0; i < 3; i++) { out.write("," + ((int) (total[i] / c))); } out.write("\n"); out.close(); rs.close(); System.out.println("finished after " + ((System.currentTimeMillis() - started) / 1000) + " seconds."); } // disconnect from database conn.close(); } Loading