[or-cvs] r15341: Extended parsing script to obtain more information about des (projects/hidserv/trunk)

kloesing at seul.org kloesing at seul.org
Tue Jun 17 22:13:56 UTC 2008


Author: kloesing
Date: 2008-06-17 18:13:56 -0400 (Tue, 17 Jun 2008)
New Revision: 15341

Modified:
   projects/hidserv/trunk/LogFileParser.java
Log:
Extended parsing script to obtain more information about descriptor publication and message transfer times.

Modified: projects/hidserv/trunk/LogFileParser.java
===================================================================
--- projects/hidserv/trunk/LogFileParser.java	2008-06-17 21:19:58 UTC (rev 15340)
+++ projects/hidserv/trunk/LogFileParser.java	2008-06-17 22:13:56 UTC (rev 15341)
@@ -6,8 +6,10 @@
 import java.io.IOException;
 import java.text.ParsePosition;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.SortedMap;
@@ -67,14 +69,27 @@
 					+ "and publtime is the \n# time in millis that it takes "
 					+ "afterwards to publish the first rendezvous \n# "
 					+ "service descriptor.\n");
-			bw.write("testid,inittime,publtime\n");
+			/* TODO: how to extend to cover n-th estipo and n-th publtime? */
+			bw.write("testid,inittime,numipos,estipo...,publtime\n");
 			for (Map.Entry<String, Long> e : initializationTimes.entrySet()) {
+				bw.write(e.getKey() + "," + e.getValue() + ","
+						+ numIntroPoints.get(e.getKey()));
+				if (introEstablishedTimes.containsKey(e.getKey())) {
+					for (long intro : introEstablishedTimes.get(e.getKey())) {
+						bw.write("," + intro);
+					}
+				}
+				if (sendingDescriptorTimes.containsKey(e.getKey())) {
+					bw.write("," + sendingDescriptorTimes.get(e.getKey()));
+				} else {
+					bw.write(",NA");
+				}
 				if (publicationTimes.containsKey(e.getKey())) {
-					bw.write(e.getKey() + "," + e.getValue() + ","
-							+ publicationTimes.get(e.getKey()) + "\n");
+					bw.write("," + publicationTimes.get(e.getKey()));
 				} else {
-					bw.write(e.getKey() + "," + e.getValue() + ",NA\n");
+					bw.write(",NA");
 				}
+				bw.write("\n");
 			}
 			bw.close();
 		} catch (IOException e) {
@@ -136,38 +151,53 @@
 			System.exit(1);
 		}
 		try {
-			BufferedWriter bw = new BufferedWriter(new FileWriter(
+			BufferedWriter bwTimes = new BufferedWriter(new FileWriter(
 					outputDirectory.getAbsolutePath() + File.separatorChar
 							+ "reqtimes.csv", false));
-			bw.write("# testid contains a unique test identifier that matches "
-					+ "with the\n# identifiers used in the other output "
-					+ "files, msgid is the message number,\n# and reqtime is "
-					+ "the time in millis that it takes to send a request "
-					+ "from\n# client to server.\n");
-			bw.write("testid,msgid,reqtime\n");
+			bwTimes.write("# testid contains a unique test identifier that "
+					+ "matches with the\n# identifiers used in the other "
+					+ "output files, msgid is the message number,\n# and "
+					+ "reqtime is the time in millis that it takes to send a "
+					+ "request from\n# client to server.\ntestid,msgid,"
+					+ "reqtime\n");
+			BufferedWriter bwAvg = new BufferedWriter(new FileWriter(
+					outputDirectory.getAbsolutePath() + File.separatorChar
+							+ "reqavg.csv", false));
+			bwAvg.write("# testid contains a unique test identifier that "
+					+ "matches with the\n# identifiers used in the other "
+					+ "output files, reqavg is the average\n# request time "
+					+ "of this test.\ntestid,reqavg\n");
 			for (Map.Entry<String, PuppeTorEvent> e : puppeTorEvents.entrySet()) {
 				PuppeTorEvent event = e.getValue();
+				StringBuilder sb = new StringBuilder();
 				if (!event.receivedRequest.isEmpty()
 						&& !event.sendingRequest.isEmpty()) {
 					int last = Math.min(event.receivedRequest.lastKey(),
 							event.sendingRequest.lastKey());
+					int count = 0;
+					long sum = 0;
 					for (int i = 0; i <= last; i++) {
-						bw.write(e.getKey() + "," + i);
+						sb.append(e.getKey() + "," + i);
 						if (event.sendingRequest.containsKey(i)
 								&& event.receivedRequest.containsKey(i)) {
 							long reqtime = event.receivedRequest.get(i)
 									- event.sendingRequest.get(i);
 							if (reqtime < 0)
 								reqtime += 24L * 60L * 60L * 1000L;
-							bw.write("," + reqtime);
+							sb.append("," + reqtime);
+							count++;
+							sum += reqtime;
 						} else {
-							bw.write(",NA");
+							sb.append(",NA");
 						}
-						bw.write("\n");
+						sb.append("\n");
 					}
+					bwTimes.write(sb.toString());
+					bwAvg.write(e.getKey() + "," + (sum / count) + "\n");
 				}
 			}
-			bw.close();
+			bwTimes.close();
+			bwAvg.close();
 		} catch (IOException e) {
 			System.err
 					.println("IOException while writing output files! Exiting.");
@@ -175,38 +205,53 @@
 			System.exit(1);
 		}
 		try {
-			BufferedWriter bw = new BufferedWriter(new FileWriter(
+			BufferedWriter bwTimes = new BufferedWriter(new FileWriter(
 					outputDirectory.getAbsolutePath() + File.separatorChar
 							+ "restimes.csv", false));
-			bw.write("# testid contains a unique test identifier that matches "
-					+ "with the\n# identifiers used in the other output "
-					+ "files, msgid is the message number,\n# and restime is "
-					+ "the time in millis that it takes to send a response "
-					+ "from\n# server to client.\n");
-			bw.write("testid,msgid,restime\n");
+			bwTimes.write("# testid contains a unique test identifier that "
+					+ "matches with the\n# identifiers used in the other "
+					+ "output files, msgid is the message number,\n# and "
+					+ "restime is the time in millis that it takes to send a "
+					+ "response from\n# server to client.\ntestid,msgid,"
+					+ "restime\n");
+			BufferedWriter bwAvg = new BufferedWriter(new FileWriter(
+					outputDirectory.getAbsolutePath() + File.separatorChar
+							+ "resavg.csv", false));
+			bwAvg.write("# testid contains a unique test identifier that "
+					+ "matches with the\n# identifiers used in the other "
+					+ "output files, resavg is the average\n# response time "
+					+ "of this test.\ntestid,resavg\n");
 			for (Map.Entry<String, PuppeTorEvent> e : puppeTorEvents.entrySet()) {
 				PuppeTorEvent event = e.getValue();
+				StringBuilder sb = new StringBuilder();
 				if (!event.receivedRequest.isEmpty()
 						&& !event.receivedResponse.isEmpty()) {
 					int last = Math.min(event.receivedRequest.lastKey(),
 							event.receivedResponse.lastKey());
+					int count = 0;
+					long sum = 0;
 					for (int i = 0; i <= last; i++) {
-						bw.write(e.getKey() + "," + i);
+						sb.append(e.getKey() + "," + i);
 						if (event.receivedResponse.containsKey(i)
 								&& event.receivedRequest.containsKey(i)) {
 							long restime = event.receivedResponse.get(i)
 									- event.receivedRequest.get(i);
 							if (restime < 0)
 								restime += 24L * 60L * 60L * 1000L;
-							bw.write("," + restime);
+							sb.append("," + restime);
+							count++;
+							sum += restime;
 						} else {
-							bw.write(",NA");
+							sb.append(",NA");
 						}
-						bw.write("\n");
+						sb.append("\n");
 					}
+					bwTimes.write(sb.toString());
+					bwAvg.write(e.getKey() + "," + (sum / count) + "\n");
 				}
 			}
-			bw.close();
+			bwTimes.close();
+			bwAvg.close();
 		} catch (IOException e) {
 			System.err
 					.println("IOException while writing output files! Exiting.");
@@ -216,11 +261,14 @@
 	}
 
 	static SortedMap<String, Long> initializationTimes = new TreeMap<String, Long>();
+	static SortedMap<String, List<Long>> introEstablishedTimes = new TreeMap<String, List<Long>>();
 	static SortedMap<String, Long> publicationTimes = new TreeMap<String, Long>();
+	static SortedMap<String, Integer> numIntroPoints = new TreeMap<String, Integer>();
+	static SortedMap<String, Long> sendingDescriptorTimes = new TreeMap<String, Long>();
 
 	static Pattern torLogPattern = Pattern
 			.compile("opening new log file|now have enough directory information|"
-					+ "Uploaded rendezvous descriptor");
+					+ "ESTABLISHED cell|Sending publish request for hidden service|Rendezvous descriptor contains router|Uploaded rendezvous descriptor");
 
 	static void parseServerTorLog(File testcaseDirectory) throws IOException {
 		File torLog = new File(testcaseDirectory.getAbsolutePath()
@@ -234,7 +282,10 @@
 		String line = null;
 		long started = 0L;
 		long enoughDirInfo = 0L;
+		long sendingDesc = 0L;
 		long firstDescriptorUploaded = 0L;
+		int numIPos = 0;
+		List<Long> introEstablished = new ArrayList<Long>();
 		while ((line = br.readLine()) != null) {
 			if (!torLogPattern.matcher(line).find())
 				continue;
@@ -252,6 +303,14 @@
 			} else if (enoughDirInfo == 0L
 					&& line.contains("now have enough directory information")) {
 				enoughDirInfo = t;
+			} else if (line.contains("ESTABLISHED cell")) {
+				introEstablished.add(t);
+			} else if (sendingDesc == 0L
+					&& line
+							.contains("Sending publish request for hidden service")) {
+				sendingDesc = t;
+			} else if (line.contains("Rendezvous descriptor contains router")) {
+				numIPos++;
 			} else if (firstDescriptorUploaded == 0L
 					&& line.contains("Uploaded rendezvous descriptor")) {
 				firstDescriptorUploaded = t;
@@ -261,13 +320,40 @@
 				break;
 			}
 		}
+		numIntroPoints.put(testcaseDirectory.getName(), numIPos);
 		if (enoughDirInfo > 0L && started > 0L) {
 			initializationTimes.put(testcaseDirectory.getName(), enoughDirInfo
 					- started);
 		}
-		if (firstDescriptorUploaded > 0L && enoughDirInfo > 0L) {
+		if (sendingDesc > 0L && !introEstablished.isEmpty()) {
+			List<Long> newIntroEstablished = new ArrayList<Long>();
+			for (long t : introEstablished) {
+				if (t < sendingDesc) {
+					newIntroEstablished.add(t);
+				}
+				introEstablished = newIntroEstablished;
+			}
+		}
+		if (!introEstablished.isEmpty()) {
+			long temp = enoughDirInfo;
+			List<Long> introEstablishedDifferences = new ArrayList<Long>();
+			for (long t : introEstablished) {
+				introEstablishedDifferences.add(t - temp);
+				temp = t;
+			}
+			introEstablishedTimes.put(testcaseDirectory.getName(),
+					introEstablishedDifferences);
+			if (sendingDesc > 0L) {
+				sendingDescriptorTimes.put(testcaseDirectory.getName(),
+						sendingDesc - temp);
+			}
+		} else if (sendingDesc > 0L) {
+			sendingDescriptorTimes.put(testcaseDirectory.getName(), sendingDesc
+					- enoughDirInfo);
+		}
+		if (firstDescriptorUploaded > 0L && sendingDesc > 0L) {
 			publicationTimes.put(testcaseDirectory.getName(),
-					firstDescriptorUploaded - enoughDirInfo);
+					firstDescriptorUploaded - sendingDesc);
 		}
 	}
 



More information about the tor-commits mailing list