Browse files

Cleaned up repository

- Removed tests that aren't used any more
- Removed unused code
- Cleaned up build scripts
  • Loading branch information...
1 parent 5f27bbb commit 1ced1f0d06a4c01cfb41a670c1df86b13459f345 David Wolinsky committed Mar 26, 2010
Showing with 38 additions and 8,357 deletions.
  1. +11 −174 Brunet.build
  2. BIN lib/NUnit.Framework.dll
  3. +0 −27 scripts/map_reduce.py
  4. +0 −18 scripts/ncservice.py
  5. +0 −39 scripts/test.py
  6. +0 −35 tests/ConfigurationTest.cs
  7. +0 −253 tests/dht/SystemTester.cs
  8. +0 −256 tests/dht/SystemTesterWithZeroConf.cs
  9. +0 −548 tests/integration/SystemTest.cs
  10. +0 −28 tests/integration/default.build
  11. +0 −301 tests/loganalysis/BrunetTcpLogger.py
  12. +0 −81 tests/loganalysis/brunetpingparse.py
  13. +0 −74 tests/loganalysis/chronilog.py
  14. +0 −86 tests/loganalysis/computerdp.py
  15. +0 −65 tests/loganalysis/icmppingparse.py
  16. +0 −50 tests/loganalysis/memorybin.py
  17. +0 −27 tests/loganalysis/nodepacketnum.py
  18. +0 −161 tests/loganalysis/packetparse.py
  19. +0 −14 tests/loganalysis/rdp_plot.gnuplot
  20. +0 −95 tests/loganalysis/reorder_confile.py
  21. +0 −43 tests/protocol/AddtoDns.cs
  22. +0 −155 tests/protocol/BrokenRingTester.cs
  23. +0 −247 tests/protocol/BrunetTester.cs
  24. +0 −257 tests/protocol/EchoTester.cs
  25. +0 −2 tests/protocol/EdgeTester.cs
  26. +0 −149 tests/protocol/MemoryTester.cs
  27. +0 −128 tests/protocol/PacketTester.cs
  28. 0 tests/protocol/{RoutingTester-1.cs → RoutingTester.cs}
  29. +0 −1,634 tests/protocol/Simulator.cs
  30. +0 −1,355 tests/protocol/TestNetwork.brunet
  31. +0 −442 tests/protocol/all_nodes.txt
  32. +27 −115 tests/protocol/default.build
  33. +0 −95 tests/protocol/remoting/BrunetRemoteObject.cs
  34. +0 −32 tests/protocol/remoting/IRemoteObject.cs
  35. +0 −9 tests/protocol/remoting/IRemoteObjectFactory.cs
  36. +0 −40 tests/protocol/remoting/RemoteObjectFactory.cs
  37. +0 −155 tests/protocol/remoting/RemotingClient.cs
  38. +0 −247 tests/protocol/remoting/RemotingTester.cs
  39. +0 −177 tests/protocol/remoting/default.build
  40. +0 −178 tests/util/NetworkConfiguration.cs
  41. +0 −73 tests/util/NodeConfiguration.cs
  42. +0 −167 tests/util/PSWrapper.cs
  43. +0 −83 tests/util/PingWrapper.cs
  44. +0 −102 tests/util/TransportAddressConfiguration.cs
  45. +0 −140 tests/util/default.build
View
185 Brunet.build
@@ -1,199 +1,36 @@
<?xml version="1.0"?>
-<project
- name="Brunet"
- default="build">
+<project name="Brunet" default="build">
+ <property name="build.dir" value="${nant.project.basedir}/build"/>
+ <property name="lib.dir" value="${nant.project.basedir}/lib"/>
+ <property name="assembly" value="Brunet"/>
- <!-- default configuration -->
- <property
- name="project.version"
- value="0.1"/>
- <property
- name="package.name"
- value="${nant.project.name}-${project.version}"/>
- <property
- name="build.dir"
- value="${nant.project.basedir}/build"/>
- <property
- name="lib.dir"
- value="${nant.project.basedir}/lib"/>
- <property
- name="assembly"
- value="Brunet"/>
- <property
- name="project.config"
- value="release"/> <!-- debug|release -->
- <property
- name="target"
- value="build"/>
- <property
- name="nunit"
- value="nunit-console"/>
-
- <!-- named configurations -->
- <target
- name="init"
- description="Initializes building properties">
- <call target="${project.config}"/>
- </target>
-
- <target
- name="debug"
- description="Configures a debug build">
- <property
- name="project.config"
- value="debug"/>
- <property
- name="build.debug"
- value="true"/>
- <property
- name="package.name"
- value="${package.name}-${project.config}"/>
- </target>
-
- <target
- name="release"
- description="Configures a release build">
- <property
- name="project.config"
- value="release"/>
- <property
- name="build.debug"
- value="false" />
- <property
- name="package.name"
- value="${package.name}-${project.config}"/>
- </target>
-
- <!-- build tasks -->
- <target
- name="recurse"
- description="Builds recursively all subprojects">
- <property
- name="configured"
- value="true"/>
+ <target name="build" description="Builds recursively all subprojects">
+ <property name="configured" value="true"/>
<nant buildfile="src/Brunet/default.build" />
<nant buildfile="src/Brunet/Services/Dht/default.build" />
<nant buildfile="src/Brunet/Services/Coordinate/default.build" />
<nant buildfile="src/Brunet/Services/XmlRpc/default.build" />
<nant buildfile="src/Brunet/Security/default.build" />
<nant buildfile="src/Brunet/Applications/default.build" />
- <nant buildfile="tests/util/default.build" />
<nant buildfile="tests/protocol/default.build" />
-
</target>
- <target
- name="recurse-plab-log"
- description="Builds recursively all subprojects">
- <property
- name="configured"
- value="true"/>
-
- <nant buildfile="src/Brunet/default.build" target="plab-log"/>
- <nant buildfile="src/Brunet/Services/Dht/default.build" />
- <nant buildfile="src/Brunet/Services/Coordinate/default.build" />
- <nant buildfile="src/Brunet/Services/XmlRpc/default.build" />
- <nant buildfile="tests/util/default.build" />
- <nant buildfile="tests/Brunet/default.build" target="plab-log"/>
-
- </target>
-
- <target
- name="build"
- depends="init"
- description="Builds the current configuration">
- <property
- name="target"
- value="build"/>
- <call target="recurse"/>
- </target>
-
- <target
- name="clean"
- depends="init"
- description="Deletes the current configuration">
- <delete
- dir="${build.dir}/${package.name}"
- failonerror="false"/>
+ <target name="clean" description="Deletes the current configuration">
+ <delete dir="${build.dir}" failonerror="false"/>
<delete failonerror="false">
<fileset basedir="lib/">
<include name="Brunet*.dll"/>
</fileset>
</delete>
-
- <delete
- file="${lib.dir}/${assembly}-TestUtil.dll"
- failonerror="false"/>
-
- </target>
-
- <target
- name="plab-log"
- depends="init"
- description="Builds the current configuration">
- <property
- name="target"
- value="build"/>
- <call target="recurse-plab-log"/>
- </target>
-
- <target
- name="test"
- description="Testing Brunet"
- depends="build">
-
- <csc target="library" output="${build.dir}/${package.name}/bin/${assembly}-Test.dll">
- <sources>
- <include name="tests/*.cs" />
- </sources>
- <references>
- <include name="${build.dir}/${package.name}/bin/NUnit.Framework.dll" />
- <include name="${build.dir}/${package.name}/bin/log4net.dll" />
- <include name="${build.dir}/${package.name}/bin/${assembly}.dll" />
- </references>
- </csc>
-
- <exec
- program="${nunit}"
- workingdir="${build.dir}/${package.name}/bin"
- commandline="${assembly}-Test.dll">
- </exec>
- </target>
-
- <target
- name="test-util"
- description="Building the Brunet Test Utilities Library"
- depends="build">
-
- <property
- name="configured"
- value="true"/>
-
- <nant buildfile="tests/util/default.build" />
-
- </target>
-
- <target
- name="test-apps"
- description="Building Brunet Test Apps/Testers"
- depends="build">
-
- <property
- name="configured"
- value="true"/>
-
- <nant buildfile="tests/Brunet/default.build" />
-
</target>
<target name="plabtest-build"
- description="make a zip file to be tested with grid-appliance.org system"
- depends="build">
- <zip zipfile="basicnode.zip"
- encoding="utf-8">
+ description="make a zip file to be tested with WebUI"
+ depends="build">
+ <zip zipfile="basicnode.zip" encoding="utf-8">
<fileset basedir="src/Brunet/Applications/build/" prefix="">
<include name="*" />
</fileset>
View
BIN lib/NUnit.Framework.dll
Binary file not shown.
View
27 scripts/map_reduce.py
@@ -1,27 +0,0 @@
-#!/usr/bin/python
-import sys, xmlrpclib, os, signal, time
-
-def run(port, nodes, debug):
- port = str(port)
- #gain access to the xmlrpc server
- rpc = xmlrpclib.Server("http://127.0.0.1:" + port + "/xm.rem")
- res = 0
- left = len(nodes) - 1
-
- node = rpc.localproxy("sys:link.GetNeighbors")['self']
-
- while left > 0:
- node = nodes[node]['right']
- try:
- ht = {}
- ht["task_name"] = "Brunet.MapReduceRangeCounter"
- ht["gen_arg"] = node
- result = rpc.localproxy("mapreduce.Start", ht)
- count = result["count"]
- if count == left:
- res += 1
- left -= 1
- except "x":
- pass
-
- return res, len(nodes) - 1
View
18 scripts/ncservice.py
@@ -1,18 +0,0 @@
-#!/usr/bin/python
-import xmlrpclib
-
-# Default starting point
-def run(port, nodes, debug):
- port = str(port)
- #gain access to the xmlrpc server
- rpc = xmlrpclib.Server("http://127.0.0.1:" + port + "/xm.rem")
- count = 0
-
- for node in nodes:
- try:
- rpc.proxy(node, 3, 1, "ncserver.EchoVivaldiState")[0]
- count += 1
- except:
- pass
-
- return count, len(nodes)
View
39 scripts/test.py
@@ -1,39 +0,0 @@
-#!/usr/bin/python
-""" This script executes a set of tests on a Brunet system using the XmlRpc
-interface. Tests must be hard coded into this file to be executed. """
-import xmlrpclib, pybru, sys, getopt, time
-import crawl, ncservice, map_reduce
-
-usage = """usage:
-python test.py [--debug] [--debug2] [--port=<xmlrpc port of a brunet node>]
-debug = debugging
-port = the xmlrpc port for a brunet node to be used for crawling
-help = this message"""
-
-tasks = [ncservice, map_reduce]
-
-# Default starting point
-def main():
- try:
- optlist, args = getopt.getopt(sys.argv[1:], "", ["debug", "port="])
-
- port = 10000
- debug = False
-
- for k,v in optlist:
- if k == "--port":
- port = int(v)
- elif k == "--debug":
- debug = True
- except:
- print usage
- return
-
- nodes = crawl.crawl(port, debug = debug)
- print crawl.check_results(nodes)
-
- for task in tasks:
- print task.run(port, nodes, debug)
-
-if __name__ == "__main__":
- main()
View
35 tests/ConfigurationTest.cs
@@ -1,35 +0,0 @@
-/*
-This program is part of BruNet, a library for the creation of efficient overlay
-networks.
-Copyright (C) 2005 University of California
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-// test fixture for cofiguration test
-
-using NUnit.Framework;
-
-[TestFixture]
-public class ConfigurationTest
- {
-
- [Test]
- public void configTest()
- {
- //Asset(1==1);
- }
-
- }
View
253 tests/dht/SystemTester.cs
@@ -1,253 +0,0 @@
-using System;
-using System.IO;
-using System.Collections;
-using System.Xml;
-using System.Xml.Serialization;
-using System.Security.Cryptography;
-using System.Text;
-using System.Threading;
-using Brunet;
-using Brunet.DistributedServices;
-
-namespace Test {
- public class SystemTest {
- static SortedList nodes = new SortedList();
- static Hashtable dhts = new Hashtable();
- static int network_size, base_time, add_remove_interval, dht_put_interval,
- dht_get_interval, max_range, add_remove_delta;
- static int base_port = 45111;
- static int DEGREE = 3;
- static Random rand = new Random();
- static string brunet_namespace = "testing";
- static Hashtable taken_ports = new Hashtable();
- static ArrayList RemoteTA = new ArrayList();
-
- public static void Main(string []args) {
- if (args.Length < 6) {
- Console.WriteLine("Input format %1 %2 %3 %4 %5 %6");
- Console.WriteLine("\t%1 = [network size]");
- Console.WriteLine("\t%2 = [base time]");
- Console.WriteLine("\t%3 = [add/remove interval]");
- Console.WriteLine("\t%4 = [add/remove delta]");
- Console.WriteLine("\t%5 = [dht put interval]");
- Console.WriteLine("\t%6 = [dht get interval]");
- Console.WriteLine("Specifying 3, 4, 5, 6 disables the event.");
- Environment.Exit(0);
- }
-
- int starting_network_size = Int32.Parse(args[0]);
- max_range = starting_network_size;
-
- base_time = Int32.Parse(args[1]);
- add_remove_interval = Int32.Parse(args[2]);
- add_remove_delta = Int32.Parse(args[3]);
- dht_put_interval = Int32.Parse(args[4]);
- dht_get_interval = Int32.Parse(args[5]);
- Console.WriteLine("Initializing...");
-
- for(int i = 0; i < max_range; i++) {
- RemoteTA.Add(TransportAddressFactory.CreateInstance("brunet.tcp://127.0.0.1:" + (base_port + i)));
- }
-
- for(int i = 0; i < starting_network_size; i++) {
- Console.WriteLine("Setting up node: " + i);
- add_node();
- }
- Console.WriteLine("Done setting up...\n");
-
- Thread system_thread = new Thread(system);
- system_thread.IsBackground = true;
- system_thread.Start();
-
- string command = String.Empty;
- while (command != "Q") {
- Console.WriteLine("Enter command (M/C/P/G/Q)");
- command = Console.ReadLine();
- if(command.Equals("C")) {
- check_ring();
- }
- else if(command.Equals("M")) {
- Console.WriteLine("Memory Usage: " + GC.GetTotalMemory(true));
- }
- else if(command.Equals("P")) {
- PrintConnections();
- }
- else if(command.Equals("G")) {
- Node node = (Node) nodes.GetByIndex(rand.Next(0, network_size));
- Dht dht = (Dht) dhts[node];
- BlockingQueue returns = new BlockingQueue();
- dht.AsyncGet(Encoding.UTF8.GetBytes("tester"), returns);
- int count = 0;
- try {
- while(true) {
- returns.Dequeue();
- count++;
- }
- }
- catch {}
- Console.WriteLine("Count: " + count);
- }
- Console.WriteLine();
- }
-
- system_thread.Abort();
-
- int lcount = 0;
- foreach(DictionaryEntry de in nodes) {
- Console.WriteLine(lcount++);
- Node node = (Node)de.Value;
- node.Disconnect();
- }
- }
-
- public static void system() {
- try {
- int interval = 1;
- while(true) {
- Thread.Sleep(base_time * 1000);
- if(add_remove_interval != 0 && interval % add_remove_interval == 0) {
- Console.Error.WriteLine("System.Test::add / removing...");
- for(int i = 0; i < add_remove_delta; i++) {
- remove_node();
- while(true) {
- try {
- add_node();
- break;
- }
- catch (ThreadAbortException) { return; }
- catch {}
- }
- }
- }
- if(dht_put_interval != 0 && interval % dht_put_interval == 0) {
- Console.Error.WriteLine("System.Test::Dht put.");
- dht_put();
- }
- if(dht_get_interval != 0 && interval % dht_get_interval == 0) {
- Console.Error.WriteLine("System.Test::Dht get.");
- dht_get();
- }
- interval++;
- }
- }
- catch (ThreadAbortException){}
- catch (Exception e){
- Console.WriteLine(e);
- }
- }
-
- private static void dht_put() {
- foreach(DictionaryEntry de in nodes) {
- Node node = (Node)de.Value;
- Dht dht = (Dht) dhts[node];
- Channel returns = new Channel();
- dht.AsyncPut(Encoding.UTF8.GetBytes("tester"),
- Encoding.UTF8.GetBytes(node.Address.ToString()),
- 2 * base_time * dht_put_interval, returns);
- }
- }
-
- private static void dht_get() {
- for(int i = 0; i < network_size / 25; i++) {
- int index = rand.Next(0, network_size);
- Node node = (Node) nodes.GetByIndex(index);
- Dht dht = (Dht) dhts[node];
- Channel returns = new Channel();
- dht.AsyncGet(Encoding.UTF8.GetBytes("tester"), returns);
- }
- }
-
- private static void remove_node() {
- int local_port = 0;
- while(!taken_ports.Contains(local_port = rand.Next(0, max_range) + base_port));
- Node node = (Node) taken_ports[local_port];
- node.Disconnect();
- nodes.RemoveAt(nodes.IndexOfValue(node));
- taken_ports.Remove(local_port);
- dhts.Remove(node);
- network_size--;
- }
-
- private static void add_node() {
- int local_port = 0;
- while(taken_ports.Contains(local_port = rand.Next(0, max_range) + base_port));
- AHAddress address = new AHAddress(new RNGCryptoServiceProvider());
- Node node = new StructuredNode(address, brunet_namespace);
- ArrayList arr_tas = new ArrayList();
- for(int j = 0; j < max_range / 10; j++) {
- int remote_port = 0;
- do {
- remote_port = rand.Next(0, max_range) + base_port;
- } while(remote_port == local_port);
- PortTAAuthorizer port_auth = new PortTAAuthorizer(remote_port);
- arr_tas.Add(port_auth);
- }
- arr_tas.Add(new ConstantAuthorizer(TAAuthorizer.Decision.Allow));
- TAAuthorizer ta_auth = new SeriesTAAuthorizer(arr_tas);
- node.AddEdgeListener(new TcpEdgeListener(local_port, null));//, ta_auth));
-// node.AddEdgeListener(new Tunnel.TunnelEdgeListener(node));
- node.RemoteTAs = RemoteTA;
- (new Thread(node.Connect)).Start();
- taken_ports[local_port] = node;
- nodes.Add((Address) address, node);
- new TableServer(node);
- dhts.Add(node, new Dht(node, DEGREE));
- network_size++;
- }
-
- private static bool check_ring() {
- Console.WriteLine("Checking ring...");
- Address start_addr = (Address) nodes.GetKeyList()[0];
- Address curr_addr = start_addr;
-
- for (int i = 0; i < network_size; i++) {
- Node node = (Node) nodes[curr_addr];
- ConnectionTable con_table = node.ConnectionTable;
- Connection con = con_table.GetLeftStructuredNeighborOf((AHAddress) curr_addr);
- if(con == null) {
- Console.WriteLine("Found no connection.");
- return false;
- }
- Console.WriteLine("Hop {2}\t Address {0}\n\t Connection to left {1}\n", curr_addr, con, i);
- Address next_addr = con.Address;
-
- if (next_addr == null) {
- Console.WriteLine("Found no connection.");
- return false;
- }
-
- Connection lc = ((Node)nodes[next_addr]).ConnectionTable.GetRightStructuredNeighborOf((AHAddress) next_addr);
- if( (lc == null) || !curr_addr.Equals(lc.Address)) {
- Address left_addr = lc.Address;
- Console.WriteLine(curr_addr + " != " + left_addr);
- Console.WriteLine("Right had edge, but left has no record of it!\n{0} != {1}", con, lc);
- return false;
- }
- else if(next_addr.Equals(start_addr) && i != network_size -1) {
- Console.WriteLine("Completed circle too early. Only {0} nodes in the ring.",
- (i + 1));
- return false;
- }
- curr_addr = next_addr;
- }
-
- if(start_addr.Equals(curr_addr)) {
- Console.WriteLine("Ring properly formed!");
- return true;
- }
- return false;
- }
-
- private static void PrintConnections() {
- foreach(DictionaryEntry de in nodes) {
- Node node = (Node)de.Value;
- IEnumerable ie = node.ConnectionTable.GetConnections(ConnectionType.Structured);
- Console.WriteLine("Connections for Node: " + node.Address);
- foreach(Connection c in ie) {
- Console.WriteLine(c);
- }
- Console.WriteLine("==============================================================");
- }
- }
- }
-}
View
256 tests/dht/SystemTesterWithZeroConf.cs
@@ -1,256 +0,0 @@
-using System;
-using System.IO;
-using System.Collections;
-using System.Xml;
-using System.Xml.Serialization;
-using System.Security.Cryptography;
-using System.Text;
-using System.Threading;
-using Brunet;
-using Brunet.DistributedServices;
-
-namespace Test {
- public class SystemTest {
- static SortedList nodes = new SortedList();
- static Hashtable dhts = new Hashtable();
- static int network_size, base_time, add_remove_interval, dht_put_interval,
- dht_get_interval, max_range, add_remove_delta;
- static int base_port = 45111;
- static int DEGREE = 3;
- static Random rand = new Random();
- static string brunet_namespace = "testing";
-// static Hashtable taken_ports = new Hashtable();
-// static ArrayList RemoteTA = new ArrayList();
-
- public static void Main(string []args) {
- if (args.Length < 6) {
- Console.WriteLine("Input format %1 %2 %3 %4 %5 %6");
- Console.WriteLine("\t%1 = [network size]");
- Console.WriteLine("\t%2 = [base time]");
- Console.WriteLine("\t%3 = [add/remove interval]");
- Console.WriteLine("\t%4 = [add/remove delta]");
- Console.WriteLine("\t%5 = [dht put interval]");
- Console.WriteLine("\t%6 = [dht get interval]");
- Console.WriteLine("Specifying 3, 4, 5, 6 disables the event.");
- Environment.Exit(0);
- }
-
- int starting_network_size = Int32.Parse(args[0]);
- max_range = starting_network_size;
-
- base_time = Int32.Parse(args[1]);
- add_remove_interval = Int32.Parse(args[2]);
- add_remove_delta = Int32.Parse(args[3]);
- dht_put_interval = Int32.Parse(args[4]);
- dht_get_interval = Int32.Parse(args[5]);
- Console.WriteLine("Initializing...");
-
- for(int i = 0; i < starting_network_size; i++) {
- Console.WriteLine("Setting up node: " + i);
- add_node();
- }
- Console.WriteLine("Done setting up...\n");
-
- Thread system_thread = new Thread(system);
- system_thread.IsBackground = true;
- system_thread.Start();
-
- string command = String.Empty;
- while (command != "Q") {
- Console.WriteLine("Enter command (M/C/P/G/Q)");
- command = Console.ReadLine();
- if(command.Equals("C")) {
- check_ring();
- }
- else if(command.Equals("P")) {
- PrintConnections();
- }
- else if(command.Equals("M")) {
- Console.WriteLine("Memory Usage: " + GC.GetTotalMemory(true));
- }
- else if(command.Equals("G")) {
- Node node = (Node) nodes.GetByIndex(rand.Next(0, network_size));
- Dht dht = (Dht) dhts[node];
- BlockingQueue returns = new BlockingQueue();
- dht.AsyncGet(Encoding.UTF8.GetBytes("tester"), returns);
- int count = 0;
- try {
- while(true) {
- returns.Dequeue();
- count++;
- }
- }
- catch {}
- Console.WriteLine("Count: " + count);
- }
- Console.WriteLine();
- }
-
- system_thread.Abort();
-
- int lcount = 0;
- foreach(DictionaryEntry de in nodes) {
- Console.WriteLine(lcount++);
- Node node = (Node)de.Value;
- node.Disconnect();
- }
- }
-
- public static void system() {
- try {
- int interval = 1;
- if(base_time <= 0) {
- base_time = -1;
- }
- else {
- base_time *= 1000;
- }
- while(true) {
- Thread.Sleep(base_time);
- if(add_remove_interval != 0 && interval % add_remove_interval == 0) {
- Console.Error.WriteLine("System.Test::add / removing...");
- for(int i = 0; i < add_remove_delta; i++) {
- remove_node();
- while(true) {
- try {
- add_node();
- break;
- }
- catch (ThreadAbortException) { return; }
- catch {}
- }
- }
- }
- if(dht_put_interval != 0 && interval % dht_put_interval == 0) {
- Console.Error.WriteLine("System.Test::Dht put.");
- dht_put();
- }
- if(dht_get_interval != 0 && interval % dht_get_interval == 0) {
- Console.Error.WriteLine("System.Test::Dht get.");
- dht_get();
- }
- interval++;
- }
- }
- catch (ThreadAbortException) { return; }
- catch (Exception e){
- Console.WriteLine(e);
- }
- }
-
- private static void dht_put() {
- foreach(DictionaryEntry de in nodes) {
- Node node = (Node)de.Value;
- Dht dht = (Dht) dhts[node];
- Channel returns = new Channel();
- dht.AsyncPut(Encoding.UTF8.GetBytes("tester"),
- Encoding.UTF8.GetBytes(node.Address.ToString()),
- 2 * base_time * dht_put_interval, returns);
- }
- }
-
- private static void dht_get() {
- for(int i = 0; i < network_size / 25; i++) {
- int index = rand.Next(0, network_size);
- Node node = (Node) nodes.GetByIndex(index);
- Dht dht = (Dht) dhts[node];
- Channel returns = new Channel();
- dht.AsyncGet(Encoding.UTF8.GetBytes("tester"), returns);
- }
- }
-
- private static void remove_node() {
- int local_port = 0;
-// while(!taken_ports.Contains(local_port = rand.Next(0, max_range) + base_port));
-// Node node = (Node) taken_ports[local_port];
- Node node = (Node) nodes[rand.Next(0, nodes.Count)];
- node.Disconnect();
- nodes.RemoveAt(nodes.IndexOfValue(node));
-// taken_ports.Remove(local_port);
- dhts.Remove(node);
- network_size--;
- }
-
- private static void add_node() {
- int local_port = 0;
-// while(taken_ports.Contains(local_port = rand.Next(0, max_range) + base_port));
- AHAddress address = new AHAddress(new RNGCryptoServiceProvider());
- Node node = new StructuredNode(address, brunet_namespace);
-/* ArrayList arr_tas = new ArrayList();
- for(int j = 0; j < max_range / 10; j++) {
- int remote_port = 0;
- do {
- remote_port = rand.Next(0, max_range) + base_port;
- } while(remote_port == local_port);
- PortTAAuthorizer port_auth = new PortTAAuthorizer(remote_port);
- arr_tas.Add(port_auth);
- }
- arr_tas.Add(new ConstantAuthorizer(TAAuthorizer.Decision.Allow));
- TAAuthorizer ta_auth = new SeriesTAAuthorizer(arr_tas);*/
- node.AddEdgeListener(new FunctionEdgeListener((new Random()).Next(1024, 65535))); //local_port, null));//, ta_auth));
-// node.AddEdgeListener(new Tunnel.TunnelEdgeListener(node));
-// node.RemoteTAs = RemoteTA;
- (new Thread(node.Connect)).Start();
-// taken_ports[local_port] = node;
- nodes.Add((Address) address, node);
- new TableServer(node);
- dhts.Add(node, new Dht(node, DEGREE));
- network_size++;
- }
-
- private static bool check_ring() {
- Console.WriteLine("Checking ring...");
- Address start_addr = (Address) nodes.GetKeyList()[0];
- Address curr_addr = start_addr;
-
- for (int i = 0; i < network_size; i++) {
- Node node = (Node) nodes[curr_addr];
- ConnectionTable con_table = node.ConnectionTable;
- Connection con = con_table.GetLeftStructuredNeighborOf((AHAddress) curr_addr);
- if(con == null) {
- Console.WriteLine("Found no connection.");
- return false;
- }
- Console.WriteLine("Hop {2}\t Address {0}\n\t Connection to left {1}\n", curr_addr, con, i);
- Address next_addr = con.Address;
-
- if (next_addr == null) {
- Console.WriteLine("Found no connection.");
- return false;
- }
-
- Connection lc = ((Node)nodes[next_addr]).ConnectionTable.GetRightStructuredNeighborOf((AHAddress) next_addr);
- if( (lc == null) || !curr_addr.Equals(lc.Address)) {
- Address left_addr = lc.Address;
- Console.WriteLine(curr_addr + " != " + left_addr);
- Console.WriteLine("Right had edge, but left has no record of it!\n{0} != {1}", con, lc);
- return false;
- }
- else if(next_addr.Equals(start_addr) && i != network_size -1) {
- Console.WriteLine("Completed circle too early. Only {0} nodes in the ring.",
- (i + 1));
- return false;
- }
- curr_addr = next_addr;
- }
-
- if(start_addr.Equals(curr_addr)) {
- Console.WriteLine("Ring properly formed!");
- return true;
- }
- return false;
- }
-
- private static void PrintConnections() {
- foreach(DictionaryEntry de in nodes) {
- Node node = (Node)de.Value;
- IEnumerable ie = node.ConnectionTable.GetConnections(ConnectionType.Structured);
- Console.WriteLine("Connections for Node: " + node.Address);
- foreach(Connection c in ie) {
- Console.WriteLine(c);
- }
- Console.WriteLine("==============================================================");
- }
- }
- }
-}
View
548 tests/integration/SystemTest.cs
@@ -1,548 +0,0 @@
-/*
-Copyright (C) 2008 David Wolinsky <davidiw@ufl.edu>, University of Florida
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-using System;
-using System.IO;
-using System.Collections;
-using System.Xml;
-using System.Xml.Serialization;
-using System.Security.Cryptography;
-using System.Threading;
-using Brunet;
-using Brunet.DistributedServices;
-
-namespace Test {
- public class SystemTest {
- static SortedList nodes = new SortedList();
- static SortedList TakenPorts = new SortedList();
-
- static int network_size = 0;
- static int time_interval = -1;
- static int add_remove_interval = 0;
- static int dht_put_interval = 0;
- static int dht_get_interval = 0;
- static int add_remove_delta = 0;
-
- static string edge_type = "function";
-
- static Random rand = new Random();
- static string brunet_namespace = "testing";
- static MemBlock dht_key = MemBlock.Reference(System.Text.Encoding.UTF8.GetBytes("tester"));
-
- static bool dht_enabled = false;
- static bool discovery = false;
-
- public static void Main(string []args) {
- int starting_network_size = 10;
- brunet_namespace += rand.Next();
-
- int carg = 0;
- while(carg < args.Length) {
- String[] parts = args[carg++].Split('=');
- try {
- switch(parts[0]) {
- case "--n":
- starting_network_size = Int32.Parse(parts[1]);
- break;
- case "--td":
- time_interval = Int32.Parse(parts[1]);
- break;
- case "--ari":
- add_remove_interval = Int32.Parse(parts[1]);
- break;
- case "--ard":
- add_remove_delta = Int32.Parse(parts[1]);
- break;
- case "--dp":
- dht_enabled = true;
- dht_put_interval = Int32.Parse(parts[1]);
- break;
- case "--dg":
- dht_enabled = true;
- dht_get_interval = Int32.Parse(parts[1]);
- break;
- case "--et":
- edge_type = parts[1];
- if(edge_type != "udp" && edge_type != "tcp" && edge_type != "function") {
- throw new Exception();
- }
- break;
- case "--discovery":
- discovery = true;
- break;
- case "--help":
- PrintHelp();
- break;
- default:
- PrintHelp();
- break;
- }
- }
- catch {
- PrintHelp();
- }
- }
-
- Console.WriteLine("Initializing...");
-
- for(int i = 0; i < starting_network_size; i++) {
- Console.WriteLine("Setting up node: " + i);
- add_node(false);
- }
-
- Console.WriteLine("Done setting up...\n");
- Thread system_thread = null;
- if(time_interval > 0) {
- system_thread = new Thread(system);
- system_thread.IsBackground = true;
- system_thread.Start();
- }
-
- string command = String.Empty;
- Console.WriteLine("Type HELP for a list of commands.\n");
- while (command != "Q") {
- Console.Write("#: ");
- // Commands can have parameters separated by spaces
- string[] parts = Console.ReadLine().Split(' ');
- command = parts[0];
-
- if(command.Equals("C")) {
- check_ring();
- }
- else if(command.Equals("P")) {
- PrintConnections();
- }
- else if(command.Equals("M")) {
- Console.WriteLine("Memory Usage: " + GC.GetTotalMemory(true));
- }
- else if(command.Equals("G")) {
- if(dht_enabled) {
- NodeMapping nm = (NodeMapping) nodes.GetByIndex(rand.Next(0, nodes.Count));
- Dht dht = nm.Dht;
- BlockingQueue returns = new BlockingQueue();
- dht.AsyncGet(dht_key, returns);
- int count = 0;
- try {
- while(true) {
- returns.Dequeue();
- count++;
- }
- }
- catch {}
- Console.WriteLine("Count: " + count);
- }
- }
- else if(command.Equals("CR")) {
- Crawl();
- }
- else if(command.Equals("A")) {
- add_node(true);
- }
- else if(command.Equals("R")) {
- remove_node(true);
- }
- else if(command.Equals("ST")) {
- int count = 1024;
- if(parts.Length > 1) {
- count = Int32.Parse(parts[1]);
- }
- SenderSpeedTest(count);
- }
- else if(command.Equals("CM")) {
- StructuredNode n = (StructuredNode) ((NodeMapping) nodes.GetByIndex(nodes.Count - 1)).Node;
- foreach(Address addr in nodes.Keys) {
- n.ManagedCO.AddAddress(addr);
- }
- }
- else if(command.Equals("HELP")) {
- Console.WriteLine("Commands: \n");
- Console.WriteLine("A - add a node");
- Console.WriteLine("R - remove a node");
- Console.WriteLine("C - check the ring using ConnectionTables");
- Console.WriteLine("P - Print connections for each node to the screen");
- Console.WriteLine("M - Current memory usage according to the garbage collector");
- Console.WriteLine("G - Retrieve total dht entries");
- Console.WriteLine("CR - Perform a crawl of the network using RPC");
- Console.WriteLine("ST - Speed test, parameter - integer - times to end data");
- Console.WriteLine("CM - ManagedCO test");
- Console.WriteLine("Q - Quit");
- }
- Console.WriteLine();
- }
-
- if(system_thread != null) {
- system_thread.Abort();
- system_thread.Join();
- }
-
- foreach(DictionaryEntry de in nodes) {
- Node node = ((NodeMapping) de.Value).Node;
- node.Disconnect();
- }
- }
-
- public static void system() {
- try {
- int interval = 1;
- while(true) {
- Thread.Sleep(time_interval * 1000);
- if(add_remove_interval != 0 && interval % add_remove_interval == 0) {
- Console.Error.WriteLine("System.Test::add / removing...");
- for(int i = 0; i < add_remove_delta; i++) {
- remove_node(false);
- add_node(false);
- }
- }
- if(dht_put_interval != 0 && interval % dht_put_interval == 0) {
- Console.Error.WriteLine("System.Test::Dht put.");
- dht_put();
- }
- if(dht_get_interval != 0 && interval % dht_get_interval == 0) {
- Console.Error.WriteLine("System.Test::Dht get.");
- dht_get();
- }
- interval++;
- }
- }
- catch (ThreadAbortException){}
- catch (Exception e){
- Console.WriteLine(e);
- }
- }
-
- private static void Crawl() {
- int count = 0, consistency = 0;
- NodeMapping nm = (NodeMapping) nodes.GetByIndex(0);
- Node lnode = nm.Node;
- Address rem_addr = lnode.Address, prev = null, first_left = null;
- bool failed = false;
- try {
- do {
- Console.WriteLine("Current address: " + rem_addr);
- ISender sender = new AHGreedySender(lnode, rem_addr);
- BlockingQueue q = new BlockingQueue();
- lnode.Rpc.Invoke(sender, q, "sys:link.GetNeighbors");
- RpcResult res = (RpcResult) q.Dequeue();
- Hashtable ht = (Hashtable) res.Result;
-
- Address tmp = AddressParser.Parse((String) ht["left"]);
- Address next = AddressParser.Parse((String) ht["right"]);
- if(prev != null && tmp.Equals(prev)) {
- consistency++;
- }
- else {
- first_left = tmp;
- }
- if(next == lnode.Address && first_left == rem_addr) {
- consistency++;
- }
- prev = rem_addr;
- rem_addr = next;
- q.Close();
- count++;
- } while((rem_addr != lnode.Address) && (count < nodes.Count));
- }
- catch(Exception e) {
- failed = true;
- Console.WriteLine("Crawl failed due to exception...");
- Console.WriteLine(e);
- }
- if(!failed) {
- if(count != nodes.Count) {
- Console.WriteLine("Crawl failed due to missing nodes!");
- Console.WriteLine("Expected nodes: {0}, found: {1}.", nodes.Count, count);
- }
- else if(consistency != count) {
- Console.WriteLine("Crawl failed due to bad consistency!");
- Console.WriteLine("Expected consistency: {0}, actual: {1}.", count, consistency);
- }
- else {
- Console.WriteLine("Crawl succeeded!");
- }
- }
- }
-
- //Sets up and performs the SenderSpeedTest
- private static void SenderSpeedTest(int max_count) {
- SenderReceiver sender = new SenderReceiver((NodeMapping) nodes.GetByIndex(0), max_count);
- NodeMapping rem_nm = (NodeMapping) nodes.GetByIndex(1);
- SenderReceiver receiver = new SenderReceiver(rem_nm, max_count);
-
- Console.WriteLine("Total time: " + sender.Send(rem_nm.Node.Address));
- }
-
- // Not implemented yet! Maybe we can get an independent study project to fill this out
- private static void RpcSpeedTest() {
- }
-
- // removes a node from the pool
- private static void remove_node(bool output) {
- int index = rand.Next(0, nodes.Count);
- NodeMapping nm = (NodeMapping) nodes.GetByIndex(index);
- if(output) {
- Console.WriteLine("Removing: " + nm.Node.Address);
- }
- nm.Node.Disconnect();
- TakenPorts.Remove(nm.Port);
- nodes.RemoveAt(index);
- network_size--;
- }
-
- // adds a node to the pool
- private static void add_node(bool output) {
- AHAddress address = new AHAddress(new RNGCryptoServiceProvider());
- Node node = new StructuredNode(address, brunet_namespace);
- NodeMapping nm = new NodeMapping();
- nm.Node = node;
- nodes.Add((Address) address, nm);
-
- nm.Port = rand.Next(1024, 65535);
- while(TakenPorts.Contains(nm.Port)) {
- nm.Port = rand.Next(1024, 65535);
- }
-
- EdgeListener el = null;
- if(edge_type.Equals("function")) {
- el = new FunctionEdgeListener(nm.Port, 0, null);
- }
- else if(edge_type.Equals("tcp")) {
- el = new TcpEdgeListener(nm.Port);
- }
- else if(edge_type.Equals("udp")) {
- el = new UdpEdgeListener(nm.Port);
- }
- node.AddEdgeListener(el);
-
- if(!discovery) {
- ArrayList RemoteTAs = new ArrayList();
- for(int i = 0; i < 5 && i < TakenPorts.Count; i++) {
- int rport = (int) TakenPorts.GetByIndex(rand.Next(0, TakenPorts.Count));
- RemoteTAs.Add(TransportAddressFactory.CreateInstance("brunet." + edge_type + "://127.0.0.1:" + rport));
- }
- node.RemoteTAs = RemoteTAs;
- }
- TakenPorts[nm.Port] = nm.Port;
-
- if(dht_enabled) {
- new TableServer(node);
- nm.Dht = new Dht(node, 3);
- }
-
- if(output) {
- Console.WriteLine("Adding: " + nm.Node.Address);
- }
- (new Thread(node.Connect)).Start();
- network_size++;
- }
-
- // Each nodes dht places a piece of data into the same dht key
- private static void dht_put() {
- foreach(DictionaryEntry de in nodes) {
- NodeMapping nm = (NodeMapping) de.Value;
- Dht dht = nm.Dht;
- Node node = nm.Node;
- Channel returns = new Channel();
- dht.AsyncPut(dht_key, node.Address.ToMemBlock(), 2 * time_interval * dht_put_interval, returns);
- }
- }
-
- // Performs network_size / 25 random dht gets
- private static void dht_get() {
- for(int i = 0; i < network_size / 25; i++) {
- int index = rand.Next(0, network_size);
- Dht dht = ((NodeMapping) nodes.GetByIndex(index)).Dht;
- Channel returns = new Channel();
- dht.AsyncGet(dht_key, returns);
- }
- }
-
- // Performs a crawl of the network using the ConnectionTable of each node.
- private static bool check_ring() {
- Console.WriteLine("Checking ring...");
- Address start_addr = (Address) nodes.GetKeyList()[0];
- Address curr_addr = start_addr;
-
- for (int i = 0; i < network_size; i++) {
- Node node = ((NodeMapping) nodes[curr_addr]).Node;
- ConnectionTable con_table = node.ConnectionTable;
-
- Connection con = null;
- try {
- con = con_table.GetLeftStructuredNeighborOf((AHAddress) curr_addr);
- }
- catch {}
-
- if(con == null) {
- Console.WriteLine("Found no connection.");
- return false;
- }
- Console.WriteLine("Hop {2}\t Address {0}\n\t Connection to left {1}\n", curr_addr, con, i);
- Address next_addr = con.Address;
-
- if (next_addr == null) {
- Console.WriteLine("Found no connection.");
- return false;
- }
-
- Connection lc = null;
- try {
- Node tnode = ((NodeMapping)nodes[next_addr]).Node;
- lc = tnode.ConnectionTable.GetRightStructuredNeighborOf((AHAddress) next_addr);
- }
- catch {}
-
- if( (lc == null) || !curr_addr.Equals(lc.Address)) {
- Address left_addr = lc.Address;
- Console.WriteLine(curr_addr + " != " + left_addr);
- Console.WriteLine("Right had edge, but left has no record of it!\n{0} != {1}", con, lc);
- return false;
- }
- else if(next_addr.Equals(start_addr) && i != network_size -1) {
- Console.WriteLine("Completed circle too early. Only {0} nodes in the ring.",
- (i + 1));
- return false;
- }
- curr_addr = next_addr;
- }
-
- if(start_addr.Equals(curr_addr)) {
- Console.WriteLine("Ring properly formed!");
- return true;
- }
- return false;
- }
-
- private static void PrintConnections() {
- foreach(DictionaryEntry de in nodes) {
- Node node = ((NodeMapping)de.Value).Node;
- IEnumerable ie = node.ConnectionTable.GetConnections(ConnectionType.Structured);
- Console.WriteLine("Connections for Node: " + node.Address);
- foreach(Connection c in ie) {
- Console.WriteLine(c);
- }
- Console.WriteLine("==============================================================");
- }
- }
-
- private static void PrintHelp() {
- Console.WriteLine("Usage: SystemTest.exe --option[=value]...\n");
- Console.WriteLine("Options:");
- Console.WriteLine("--n=int - network size");
- Console.WriteLine("--et=str - edge type - udp, tcp, or function");
- Console.WriteLine("--td=int - time interval - base time between events");
- Console.WriteLine("--ari=int - add remove interval - td * ari is how often nodes are added/removed");
- Console.WriteLine("--ard=int - amount of nodes to add and remove at each td * ari");
- Console.WriteLine("--dg=int - dht get performed at every dg*td");
- Console.WriteLine("--dp=int - dht put performed at every dp*td");
- Console.WriteLine("--discovery - enables discovery");
- Console.WriteLine("--help - this menu");
- Console.WriteLine();
- Environment.Exit(0);
- }
-
- public class NodeMapping {
- public int Port;
- public Dht Dht;
- public Node Node;
- }
-
- /*
- * The sender test! Node sends data to remote node and then waits for a
- * signal to acknowledge the completion of data sending. Data sending
- * is complete when the remote end has received the end of transfer packet.
- * Just in case of packet loss, there is a timeout on the AutoResetEvent.
- * Due to overload on the system, the Sender will send 1024 packets, wait
- * for an ACK via an AutoResetEvent and then send another 1024.
- */
- public class SenderReceiver: IDataHandler {
- NodeMapping _nm;
- int count = 0;
- static AutoResetEvent _all_done = new AutoResetEvent(false);
- // Length of the data packet
- int length = 1024;
- int _max_count;
- // This is used for synchronization
- static readonly ICopyable eos;
- static readonly MemBlock eos_data;
- static readonly PType testing;
-
- static SenderReceiver() {
- testing = new PType("g");
- byte[] end_of_send = new byte[10];
- for(int i = 0; i < end_of_send.Length; i++) {
- end_of_send[i] = 254;
- }
- eos_data = MemBlock.Reference(end_of_send);
- eos = new CopyList(testing, eos_data);
- }
-
- public SenderReceiver(NodeMapping nm, int max_count) {
- _nm = nm;
- _nm.Node.GetTypeSource(testing).Subscribe(this, null);
- _max_count = max_count;
- _all_done.Reset();
- }
-
- // The the packet is an eos, set _all_done otherwise ignore it...
- // This could have a counter on it to match a counter on send to ensure
- // all packets arrive prior to calling _all_done...
- public void HandleData(MemBlock b, ISender return_path, object state) {
- if(b.Equals(eos_data)) {
- _all_done.Set();
- }
- }
-
- // This is called once per test and performs max_count as defined in the
- // constructor
- public int Send(Address rem_addr) {
- // Get a random set of data
- byte[]data = new byte[length];
- RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
- rng.GetBytes(data);
- // Add the appropriate header to the data block
- testing.ToMemBlock().CopyTo(data, 0);
- MemBlock to_send = MemBlock.Reference(data);
- // Setup the sender
- ISender sender = new AHExactSender(_nm.Node, rem_addr);
-
- // perform the send test
- DateTime now = DateTime.UtcNow;
- for(int i = 1; i <= _max_count; i++) {
- // at every 102400 packet, we syncrhonize and force a GC otherwise
- // memory tends to explode
- if(i % (102400) != 0) {
- sender.Send(MemBlock.Reference(to_send));
- }
- else {
- sender.Send(eos);
- _all_done.WaitOne();
- Thread.Sleep(500);
- GC.Collect();
- }
- }
-
- // All done, now let's send and wait!
- sender.Send(eos);
- if(!_all_done.WaitOne(10000, false)) {
- Console.WriteLine("Failed");
- }
- return (int) (DateTime.UtcNow - now).TotalMilliseconds;
- }
- }
- }
-}
View
28 tests/integration/default.build
@@ -1,28 +0,0 @@
-<?xml version="1.0"?>
-<project name="security-test" default="build" basedir=".">
- <description> Builds security-test </description>
- <property name="debug" value="true" overwrite="false" />
- <property name="lib.dir" value="../../lib"/>
- <property name="build.dir" value="build" />
- <target name="clean" description="Remove build directory">
- <delete dir="${build.dir}" failonerror="true"/>
- </target>
- <target name="build" description="Build Integration tests">
- <mkdir dir="${build.dir}" failonerror="true"/>
- <copy todir="${build.dir}" failonerror="true">
- <fileset basedir="${lib.dir}">
- <include name="Brunet.dll"/>
- <include name="Brunet.Dht.dll"/>
- </fileset>
- </copy>
- <csc target="exe" output="${build.dir}/SystemTest.exe">
- <sources failonempty="true">
- <include name="SystemTest.cs"/>
- </sources>
- <references>
- <include name="${build.dir}/Brunet.dll"/>
- <include name="${build.dir}/Brunet.Dht.dll"/>
- </references>
- </csc>
- </target>
-</project>
View
301 tests/loganalysis/BrunetTcpLogger.py
@@ -1,301 +0,0 @@
-#!/usr/bin/env python
-import asynchat, asyncore, socket, select, os,urllib, urlparse,cStringIO
-import sys,re, threading
-from datetime import timedelta, datetime
-
-class request_handler(asynchat.async_chat):
- def __init__(self,conn,addr,server):
- asynchat.async_chat.__init__(self,conn)
- self.client_address=addr
- self.connection=conn
- self.server=server
- self.buffer = ""
- self.set_terminator("\n")
- self.regexp = re.compile('(\w*)_(\d*)')
- self.client_brunet_address = -1
- print "Connect: " , self.client_address
- def collect_incoming_data(self,data):
- #Collects the incoming data
- self.buffer = self.buffer + data
- def process_log_line(self,logtype,logversion,split_line):
- if logtype in self.server.log_protocols:
- #print split_line
- self.client_brunet_address = int(split_line[4])
- #self.server.last_delete_time[r_a] = None
- self.server.log_protocols[logtype].process_line(logversion,split_line)
- else:
- print "ERROR: unknown protocol"
- def found_terminator(self):
- tmp_list = []
- init_parsed_line = self.buffer.split()
- logtype = "UNDEFINED"
- logversion = -1
- match = self.regexp.match(init_parsed_line[0])
- if match:
- logtype = match.group(1)
- logversion = int( match.group(2) )
- else:
- print "NO MATCH"
- split_line = []
- if self.server.use_local_times is True:
- tmp_time = datetime.utcnow()
- split_line.append(tmp_time.strftime("%m/%d/%Y"))
- time_str = "%s%i" % ( tmp_time.strftime("%T:") ,
- int(tmp_time.microsecond/1000) )
- split_line.append(time_str)
- for loop in init_parsed_line[3:len(init_parsed_line)]:
- split_line.append(loop)
- else:
- split_line = init_parsed_line[1:len(init_parsed_line)]
-
- self.process_log_line(logtype,logversion,split_line)
- self.buffer = ""
-
- def handle_close(self):
- print "Disconnect: " , self.client_address
- current_dt = datetime.utcnow()
- init_parsed_line = []
- init_parsed_line.append("con_0")
- tmp_time = datetime.utcnow()
- init_parsed_line.append(tmp_time.strftime("%m/%d/%Y"))
- time_str = "%s%i" % ( tmp_time.strftime("%T:") ,
- int(tmp_time.microsecond/1000) )
- init_parsed_line.append(time_str)
- init_parsed_line.append("deletion")
- init_parsed_line.append("deletion")
- init_parsed_line.append(str(self.client_brunet_address))
- init_parsed_line.append(str(self.client_brunet_address))
- init_parsed_line.append("deletion")
-
- print init_parsed_line
-
- logtype = "UNDEFINED"
- logversion = -1
- match = self.regexp.match(init_parsed_line[0])
- if match:
- logtype = match.group(1)
- logversion = int( match.group(2) )
- else:
- print "NO MATCH"
- split_line = init_parsed_line[1:len(init_parsed_line)]
- self.process_log_line(logtype,logversion,split_line)
-
- self.connection.close()
- self.close()
-class Server(asyncore.dispatcher):
- def __init__ (self, ip, port,handler,log_protocols,use_local_times):
- self.ip = ip
- self.port = port
- self.handler=handler
- asyncore.dispatcher.__init__ (self)
- self.create_socket (socket.AF_INET, socket.SOCK_STREAM)
- self.set_reuse_addr()
- self.bind ((ip, port))
- self.listen (1024)
- self.log_dictionary = {}
- self.log_protocols = log_protocols
- self.use_local_times = use_local_times
- # node address --> last log time for address
- #self.last_log_time = {}
- # node address --> last time address was deleted
- #self.last_delete_time = {}
- def handle_accept (self):
- try:
- conn, addr = self.accept()
- except socket.error:
- print socket.error
- return
- except TypeError:
- print TypeError
- return
- # creates an instance of the handler class to handle the request/response
- # on the incoming connection
- self.handler(conn,addr,self)
-
-# base class of all logging protocols
-class BrunetLogProtocol:
- def __init__(self):
- self.type = None
- self.versions = {}
- def process_line(self,parsed_line):
- pass
-# log protocol for acquiring Brunet Connection logs
-# this is currently the only protocol that we need to log
-# over the Network. All versions of the protocol are
-#stored in this class
-class ConnectionLogProtocol(BrunetLogProtocol):
- def __init__(self,log_interval):
- BrunetLogProtocol.__init__(self)
- BrunetLogProtocol.type = "con"
- tmp_version = ConnectionLogV0(log_interval)
- self.versions.setdefault(0,tmp_version)
- def process_line(self,version,parsed_line):
- if version in self.versions:
- self.versions[version].process_line(parsed_line)
- else:
- print "ERROR: unknown version"
-# converts the date/time format in the connection log into python datetime
-# objects
-class ParseBrunetTime:
- def __init__(self,tmp_date,tmp_time):
- p_d = tmp_date.split('/')
- p_t = tmp_time.split(':')
- year = int(p_d[2])
- month = int(p_d[0])
- day = int(p_d[1])
- hour = int(p_t[0])
- minute = int(p_t[1])
- second = int(p_t[2])
- microsecond = 1000*int(p_t[3])
- self.timestamp = datetime(year,month,day,hour,minute,second,microsecond)
- def to_datetime(self):
- return self.timestamp
-# the first version (V0) of the Connection log format.
-# future versions can be accomodated by adding additional
-# versions to the version dictionary in the __main__ loop
-class ConnectionLogV0:
- def __init__(self,log_interval):
- self.log_dictionary = {}
- self.interval = log_interval
- self.total_time = 0 + self.interval
- self.write_timer = None
- self.first_dump = True
- self.first_run = True
- self.file_name = "confile.txt.tmp"
- self.map_file_name = "mapconfile.txt.tmp"
- self.file_name_new = "confile.txt"
- self.map_file_name_new = "mapconfile.txt"
- self.con_file = None
- self.map_con_file = None
- self.last_dump_time = datetime.now()
- self.last_process_time = None
- self.bigints = {}
- def process_line(self,parsed_line):
- self.last_process_time = datetime.now()
- if self.first_run is True:
- self.write_timer = threading.Timer(self.interval,self.dump_results)
- self.first_run = False
- self.write_timer.start()
- pbt = ParseBrunetTime(parsed_line[0],parsed_line[1])
- current_dt = pbt.to_datetime()
- tmp_list = []
- ConHashLock.acquire()
- if current_dt in self.log_dictionary:
- tmp_list = self.log_dictionary[current_dt]
- tmp_list.append(parsed_line)
- self.log_dictionary[current_dt] = tmp_list
- else:
- tmp_list.append(parsed_line)
- self.log_dictionary[current_dt] = tmp_list
- local_i = int(parsed_line[4])
- self.bigints.setdefault(local_i)
- remote_i = int(parsed_line[5])
- self.bigints.setdefault(remote_i)
- ConHashLock.release()
- def unlocked_process_line(self,parsed_line):
- self.last_process_time = datetime.now()
- if self.first_run is True:
- self.write_timer = threading.Timer(self.interval,self.dump_results)
- self.first_run = False
- self.write_timer.start()
- pbt = ParseBrunetTime(parsed_line[0],parsed_line[1])
- current_dt = pbt.to_datetime()
- tmp_list = []
- #ConHashLock.acquire()
- if current_dt in self.log_dictionary:
- tmp_list = self.log_dictionary[current_dt]
- tmp_list.append(parsed_line)
- self.log_dictionary[current_dt] = tmp_list
- else:
- tmp_list.append(parsed_line)
- self.log_dictionary[current_dt] = tmp_list
- local_i = int(parsed_line[4])
- self.bigints.setdefault(local_i)
- remote_i = int(parsed_line[5])
- self.bigints.setdefault(remote_i)
- #ConHashLock.release()
-
- def dump_results(self):
- ConHashLock.acquire()
- do_dump = False
- if self.first_dump is True:
- do_dump = True
- self.first_dump = False
- elif self.last_dump_time < self.last_process_time:
- do_dump = True
-
- if do_dump is True:
- delfile = None
- delfilename = "./manual_log_insertion.txt"
- if os.path.exists(delfilename):
- delfile = open(delfilename, 'r')
- man_del_lines = delfile.readlines()
- for d_line in man_del_lines:
- s_line = d_line.split()
- print "T ", s_line
- if len(s_line) > 4:
- self.unlocked_process_line( s_line )
- delfile.close()
- os.remove(delfilename)
-
- sorted_ints = self.bigints.keys()
- sorted_ints.sort()
- tmp_int = 0
- self.map_con_file = open( self.map_file_name, 'w')
- for b_add in sorted_ints:
- self.map_con_file.write("%i ---> %i\n" % (tmp_int , b_add ) )
- self.bigints[b_add] = tmp_int
- tmp_int = tmp_int + 1
- self.map_con_file.close()
- os.rename( self.map_file_name,self.map_file_name_new)
-
- sorted_keys = self.log_dictionary.keys()
- sorted_keys.sort()
- self.con_file = open( self.file_name, 'w')
- for loop in sorted_keys:
- t_l = self.log_dictionary[loop]
- for t_l_el in t_l:
- if len(t_l_el) > 4:
- local_i = int(t_l_el[4])
- local_sm = self.bigints[local_i]
- remote_i = int(t_l_el[5])
- remote_sm = self.bigints[remote_i]
- if loop.microsecond == 0 :
- tmp_str = "%s.000000 %s %s %i %i %s" % (loop,t_l_el[2], \
- t_l_el[3],local_sm,remote_sm,t_l_el[6] ) #, \
- self.con_file.write("%s\n" % (tmp_str ) )
- else:
- tmp_str = "%s %s %s %i %i %s" % (loop,t_l_el[2], \
- t_l_el[3],local_sm,remote_sm,t_l_el[6] ) #, \
- self.con_file.write("%s\n" % (tmp_str ) )
- else:
- print len(t_l_el)
- self.con_file.close()
- os.rename(self.file_name,self.file_name_new)
- self.last_dump_time = datetime.now()
- #self.total_time = self.interval + self.total_time
- #self.file_name = "confile.txt.tmp" % (self.total_time)
- #self.con_file = open( self.file_name, 'w')
- #self.map_file_name = "mapconfile.txt.tmp" % (self.total_time)
- #self.map_con_file = open( self.map_file_name, 'w')
- self.write_timer = threading.Timer(self.interval,self.dump_results)
- self.write_timer.start()
- ConHashLock.release()
-
-ConHashLock = threading.RLock()
-
-#global dictionary of deleted addresses
-DeleteHashLock = threading.RLock()
-DeleteHashTable = {}
-
-if __name__=="__main__":
- # launch the server on port 8080
- log_interval = sys.argv[1]
- use_local_times = False
- port = 8003
- log_protocols = {}
- con_prot = ConnectionLogProtocol( int(log_interval) )
- log_protocols.setdefault("con", con_prot)
- s=Server('',port, request_handler,log_protocols,use_local_times)
- print "BruNet data logger running on port %s" % port
- asyncore.loop()
View
81 tests/loganalysis/brunetpingparse.py
@@ -1,81 +0,0 @@
-#!/usr/bin/env python
-#
-# This takes a Brunet connection log and parses it into a graph
-# The current version takes the whole log.
-#
-import sys, time, copy, stats
-from datetime import timedelta, datetime
-
-
-class BruNetPingParse:
- def __init__(self,infilename):
- self.ifile = open( infilename, 'r')
- self.sent_uid_to_time = {}
- self.received_uid_in_sent_to_time = {}
- self.time_to_sent_uid = {}
- self.ping_times = []
- self.local_node = None
- self.remote_node = None
- def parse(self):
- line = self.ifile.readline()
- while line:
- self.process_line(line)
- line = self.ifile.readline()
- self.output_results()
-
- def process_line(self,line):
- parsed_line = line.split()
- if parsed_line[0] == 'local:' :
- self.process_header_line(parsed_line)
- else:
- self.process_data_line(parsed_line)
-
- def output_results(self):
- c1 = len(self.sent_uid_to_time) > 0
- c2 = len(self.received_uid_in_sent_to_time) > 0
- if c1 and c2:
- sorted_ids = self.time_to_sent_uid.keys()
- sorted_ids.sort()
- for s_time in sorted_ids:
- rec = self.time_to_sent_uid[s_time]
- t_time = -1
- if rec in self.received_uid_in_sent_to_time:
- t_time = self.received_uid_in_sent_to_time[rec]- \
- self.sent_uid_to_time[rec]
- # if t_time > 0.0:
- self.ping_times.append(t_time)
- self.sent_uid_to_time = {}
- self.received_uid_in_sent_to_time = {}
- self.time_to_sent_uid = {}
- if len(self.ping_times) > 0:
- tmp_str = ""
- for f_time in self.ping_times:
- tmp_str = tmp_str + str(f_time) + " "
- self.ping_times = []
- print "%s %s %s" % (self.local_node,self.remote_node, tmp_str)
-
- def process_header_line(self,parsed_line):
-
- self.output_results()
- self.local_node = parsed_line[1]
- self.remote_node = parsed_line[3]
-
- def process_data_line(self,parsed_line):
- tmp_time = float(parsed_line[0])
- tmp_status = parsed_line[1]
- tmp_uid = int(parsed_line[2])
-
- if tmp_status == 'sent':
- self.sent_uid_to_time[tmp_uid] = tmp_time
- self.time_to_sent_uid[tmp_time] = tmp_uid
- elif tmp_status == 'received':
- if tmp_uid in self.sent_uid_to_time:
- self.received_uid_in_sent_to_time[tmp_uid]= tmp_time
- else:
- print 'ERROR unknown packet direction'
-
-
-if __name__=="__main__":
- infilename = sys.argv[1]
- parser = BruNetPingParse(infilename)
- parser.parse()
View
74 tests/loganalysis/chronilog.py
@@ -1,74 +0,0 @@
-#!/usr/bin/env python
-#
-# This takes a Brunet connection log and parses it into a graph
-# The current version takes the whole log.
-#
-import sys, time, copy, stats
-from datetime import timedelta, datetime
-infilename = sys.argv[1]
-mapfilename = infilename + '.address_map'
-
-ifile = open( infilename, 'r') # r for reading
-mapfile = open( mapfilename, 'w') # w for writing
-
-time_to_data_list = {}
-ah_addresses = []
-tmp_local_address = 0
-rand_address_to_sequential_int = {}
-for line in ifile:
- parsed_line = line.split()
- if parsed_line[0] == 'local_address' :
- tmp_local_address = int(parsed_line[1])
- rand_address_to_sequential_int[tmp_local_address]= 1
- else :
- if len( parsed_line) > 4:
- tmp_date = parsed_line[0]
- tmp_time = parsed_line[1]
- p_d = tmp_date.split('/')
- p_t = tmp_time.split(':')
- year = int(p_d[2])
- month = int(p_d[0])
- day = int(p_d[1])
- hour = int(p_t[0])
- minute = int(p_t[1])
- second = int(p_t[2])
- microsecond = 1000*int(p_t[3])
- tmp_time = datetime(year,month,day,hour,minute,second,microsecond)
- tmp_data = []
- tmp_data.append(parsed_line[2])
- tmp_data.append(parsed_line[3])
- tmp_data.append(tmp_local_address)
- tmp_data.append( int(parsed_line[4]) )
-
- if tmp_time in time_to_data_list:
- tmp_existing_list = time_to_data_list[tmp_time]
- tmp_existing_list.append(tmp_data)
- else:
- tmp_new_list = []
- tmp_new_list.append(tmp_data)
- time_to_data_list[tmp_time] = tmp_new_list
-
-brunet_addresses = rand_address_to_sequential_int.keys()
-brunet_addresses.sort()
-tmp_int = 0
-for b_add in brunet_addresses:
- rand_address_to_sequential_int[b_add]= tmp_int
- tmp_int = tmp_int + 1
-
-hash_invert = {}
-for b_add in brunet_addresses:
- hash_invert[rand_address_to_sequential_int[b_add] ] = b_add
-
-inverted = hash_invert.keys()
-for sm_int in inverted:
- mapfile.write("%i ---> %i\n" % (sm_int,hash_invert[sm_int]) )
-
-timestamps = time_to_data_list.keys()
-timestamps.sort()
-for time_it in timestamps:
- for tr in time_to_data_list[time_it]:
- print time_it,tr[0],tr[1],rand_address_to_sequential_int[tr[2]],rand_address_to_sequential_int[tr[3]]
-
-
-
-
View
86 tests/loganalysis/computerdp.py
@@ -1,86 +0,0 @@
-#!/usr/bin/env python
-#
-# This takes a Brunet connection log creates an RDP record
-# The current version takes the whole log.
-#
-import sys, time, copy, stats, math
-from datetime import timedelta, datetime
-infilename = sys.argv[1]
-infilename2 = sys.argv[2]
-
-ifile_brunet = open( infilename, 'r') # r for reading
-ifile_icmp = open( infilename2, 'r') # r for reading
-
-# the bin size in milliseconds
-binsize = 5
-
-brunet_address_pair_to_times = {}
-icmp_address_pair_to_times = {}
-
-timebin_to_time_list = {}
-
-line = ifile_brunet.readline()
-while line:
- parsed_line = line.split()
- tmp_address_pair = parsed_line[0] + " " + parsed_line[1]
- tmp_len = len(parsed_line)
- tmp_str_list = parsed_line[3:]
- tmp_list = []
- for strnum in tmp_str_list :
- tmp_list.append( float(strnum) )
- brunet_address_pair_to_times[tmp_address_pair] = tmp_list
- line = ifile_brunet.readline()
-ifile_brunet.close()
-
-line = ifile_icmp.readline()
-while line:
- parsed_line = line.split()
- tmp_address_pair = parsed_line[0] + " " + parsed_line[1]
- tmp_len = len(parsed_line)
- tmp_str_list = parsed_line[3:]
- tmp_list = []
- for strnum in tmp_str_list :
- tmp_list.append( float(strnum) )
- icmp_address_pair_to_times[tmp_address_pair] = tmp_list
- line = ifile_icmp.readline()
-ifile_icmp.close()
-
-count = 0
-for add_pair in brunet_address_pair_to_times :
- if add_pair in icmp_address_pair_to_times :
- count = count +1
- icmp_time_list = icmp_address_pair_to_times[add_pair]
- brunet_time_list = brunet_address_pair_to_times[add_pair]
- icmp_len = len(icmp_time_list)
- bn_len = len(brunet_time_list)
- loop_count = bn_len
- rdp_list = []
- rdp_tmp = 0.0
- if icmp_len < bn_len :
- loop_count = icmp_len
- for i in range(loop_count) :
- if brunet_time_list[i] != -1.0 and icmp_time_list[i] != -1.0 :
- if brunet_time_list[i] != 0.0 and icmp_time_list[i] != 0.0 :
- bin_index = math.floor(icmp_time_list[i]/binsize)*binsize
- rdp_tmp = brunet_time_list[i]/icmp_time_list[i]
- tmp1_list = []
- if bin_index in timebin_to_time_list :
- tmp1_list = timebin_to_time_list[bin_index]
- tmp1_list.append(rdp_tmp)
- else :
- timebin_to_time_list[bin_index] = [rdp_tmp]
- timebin_to_time_list[bin_index] = tmp1_list
-
-#print timebin_to_time_list
-
-bin_final_list = timebin_to_time_list.keys()
-bin_final_list.sort()
-
-for bin in bin_final_list :
- if len(timebin_to_time_list[bin]) > 0:
- tmed = stats.lmedian(timebin_to_time_list[bin],100000 )
- tmp_scor_list = timebin_to_time_list[bin]
- tmp_scor_list.sort()
- nin = int( math.floor( 0.9*len(tmp_scor_list) ) )
- tstdband = tmp_scor_list[nin]
- print bin, min(tmp_scor_list),tmed ,tstdband
View
65 tests/loganalysis/icmppingparse.py
@@ -1,65 +0,0 @@
-#!/usr/bin/env python
-#
-# This takes a Brunet connection log and parses it into a graph
-# The current version takes the whole log.
-#
-import sys, time, copy, stats
-from datetime import timedelta, datetime
-infilename = sys.argv[1]
-
-ifile = open( infilename, 'r') # r for reading
-
-#brunetpingoutname = infilename + "brunet_ping.txt"
-#outfile = open(brunetpingoutname, 'w')
-
-# read the data
-tmp_address = ""
-
-num_packets = 0
-num_bytes = 0
-
-sent_time_to_delta_time = {}
-count = 0
-needs_to_write = False
-uid_to_sent_time = {}
-uid_to_received_time = {}
-uid_to_all_received_time = {}
-
-nodes_at_t = 0
-local_node = ''
-remote_node = ''
-line = ifile.readline()
-tmp_time = 0.0
-tmp_status = ''
-tmp_uid = 0
-delta_list = []
-if line:
- parsed_line = line.split()
- if parsed_line[0] == 'local:' :
- local_node = parsed_line[1]
- remote_node = parsed_line[3]
- line = ifile.readline()
- while line:
- parsed_line = line.split()
- if parsed_line[0] != 'local:' :
- delta_list.append( float(parsed_line[1]) )
- else:
- tmp_str = " "
- for number in delta_list:
- tmp_str = tmp_str + str(number) + " "
- print local_node,remote_node,"icmp_ping",tmp_str
- delta_list = []
- if len(parsed_line) > 1:
- local_node = parsed_line[1]
- remote_node = parsed_line[3]
-
- line = ifile.readline()
-
-#for time_it in timestamps:
-# if len(datetime_to_bytelist[time_it]) > 1:
-# mtmp = stats.mean(datetime_to_bytelist[time_it])
-# vtmp = stats.var(datetime_to_bytelist[time_it])
-# bytestatsout.write( "%s %f %f %i\n" % (time_it,mtmp,vtmp,len(datetime_to_bytelist[time_it])) )
-# else :
-# mtmp = stats.mean(datetime_to_bytelist[time_it])
-# bytestatsout.write( "%s %f -1 %i\n" % ( time_it,mtmp,len(datetime_to_bytelist[time_it]) ) )
View
50 tests/loganalysis/memorybin.py
@@ -1,50 +0,0 @@
-#!/usr/bin/env python
-#
-# This takes a Brunet memory log and parses it
-# The 10% memory, mean memory, and 90% memory footprint for each
-# time bin is output.
-
-# currently the header line for each node needs to be stripped off...or code
-# needs to be added to skip lines that are the node headers.
-
-import sys, time, copy, stats, math
-from datetime import timedelta, datetime
-infilename = sys.argv[1]
-
-ifile_brunet = open( infilename, 'r') # r for reading
-
-# the bin size in milliseconds
-binsize = 5000.0
-
-time_to_rss_list = {}
-
-
-line = ifile_brunet.readline()
-while line:
- parsed_line = line.split()
- if len(parsed_line) > 1 :
- rss = float(parsed_line[1])
- bin_index = math.floor(float(parsed_line[0])/binsize)*binsize
- if bin_index in time_to_rss_list :
- tmp_list = time_to_rss_list[bin_index]
- tmp_list.append(rss)
- time_to_rss_list[bin_index] =tmp_list
- else :
- tmp_list = [rss]
- time_to_rss_list[bin_index] =tmp_list
- line = ifile_brunet.readline()
-
-bin_final_list = time_to_rss_list.keys()
-bin_final_list.sort()
-
-for bin in bin_final_list :
- if len(time_to_rss_list[bin]) > 1:
- tmean = stats.mean(time_to_rss_list[bin])
- tmp_scor_list = time_to_rss_list[bin]
- tmp_scor_list.sort()
- nin = int( math.floor( 0.9*len(tmp_scor_list) ) )
- tstdband = tmp_scor_list[nin]
- nin = int( math.floor( 0.1*len(tmp_scor_list) ) )
- tstdlowband = tmp_scor_list[nin]
-
- print bin, tstdlowband,tmean ,tstdband
View
27 tests/loganalysis/nodepacketnum.py
@@ -1,27 +0,0 @@
-#!/usr/bin/env python
-#
-# This takes a Brunet connection log and parses it into a graph
-# The current version takes the whole log.
-#
-import sys
-infilename = sys.argv[1]
-
-ifile = open( infilename, 'r') # r for reading
-
-total_packets = 0
-needs_to_write = False
-last_name = ''
-
-for line in ifile:
- parsed_line = line.split()
- if parsed_line[0] == 'Local_node:' :
- if False == needs_to_write :
- pass
- else:
- print last_name,total_packets
- total_packets = 0
- if len(parsed_line) > 1 :
- last_name = parsed_line[1]
- else:
- needs_to_write = True
- total_packets = total_packets + 1
View
161 tests/loganalysis/packetparse.py
@@ -1,161 +0,0 @@
-#!/usr/bin/env python
-#
-# This takes a Brunet connection log and parses it
-# The current version takes the whole log.
-#
-import sys, time, copy, stats
-from datetime import timedelta, datetime
-infilename = sys.argv[1]
-
-# bin size (milliseconds)
-deltatime = timedelta( milliseconds = float(sys.argv[2]) )
-direction = "total"
-#direction = sys.argv[3] # this should be "sent, received, total"
-
-ifile = open( infilename, 'r') # r for reading
-
-packetstatsname = infilename + "packet_output.txt"
-packetstatsout = open(packetstatsname, 'w')
-bytestatsname = infilename + "bytes_stats_output.txt"
-bytestatsout = open(bytestatsname, 'w')
-
-# read the data
-tmp_address = ""
-start_time = datetime.today()
-outputtime = datetime.today()
-
-num_packets = 0
-num_bytes = 0
-
-deltaincr = copy.deepcopy(deltatime)
-tmpdeltamultiple = 1
-datetime_to_packetlist = {}
-datetime_to_bytelist = {}
-
-count = 0
-needs_to_write = False
-
-nodes_at_t = 0
-
-for line in ifile:
- #count = count +1
- #print count
- parsed_line = line.split()
- if parsed_line[0] == 'Local_node:' :
- if needs_to_write == True:
- outputtime = start_time + deltaincr*tmpdeltamultiple
- #print outputtime.ctime()
- #print "-----"
-
- if outputtime in datetime_to_packetlist:
- t_list = datetime_to_packetlist[outputtime]
- t_list.append(num_packets)
- datetime_to_packetlist[outputtime] = t_list
- else :
- datetime_to_packetlist[outputtime] = [num_packets]
-
- if outputtime in datetime_to_bytelist:
- t_list = datetime_to_bytelist[outputtime]
- t_list.append(num_bytes)
- datetime_to_bytelist[outputtime] = t_list
- else :
- datetime_to_bytelist[outputtime] = [num_bytes]
- num_packets = 0
- num_bytes = 0
-
- tmpdeltamultiple = 1
- #print parsed_line[0] , parsed_line[1] , parsed_line[3] ,parsed_line[4]
-
- if len( parsed_line) > 1:
- num_packets = 0
- num_bytes = 0
- tmp_address = parsed_line[1]
- tmp_date = parsed_line[3]
- tmp_time = parsed_line[4]
- p_d = tmp_date.split('/')
- p_t = tmp_time.split(':')
- year = int(p_d[2])
- month = int(p_d[0])
- day = int(p_d[1])
- hour = int(p_t[0])
- minute = int(p_t[1])
- second = int(p_t[2])
- start_time = datetime(year,month,day,hour,minute,second)
- deltaincr = copy.deepcopy(deltatime)
- else:
- c_f = float(parsed_line[0])/1000.0
- packetdelta = timedelta( seconds = c_f )
-
- packetbytes = int(parsed_line[1])
- needs_to_write = True
- outputtime = start_time + deltaincr*tmpdeltamultiple
- #print outputtime.ctime()
- if deltaincr*tmpdeltamultiple > packetdelta :
- if direction == 'total' :
- num_packets = num_packets + 1
- num_bytes = num_bytes + packetbytes
- elif parsed_line[3] == direction:
- num_packets = num_packets + 1
- num_bytes = num_bytes + packetbytes
- else:
- print "ERROR in line parsing"
- else :
- needs_to_write = False
- outputtime = start_time + deltaincr*tmpdeltamultiple
-
- if outputtime in datetime_to_packetlist:
- t_list = datetime_to_packetlist[outputtime]
- t_list.append(num_packets)
- datetime_to_packetlist[outputtime] = t_list
- else :
- datetime_to_packetlist[outputtime] = [num_packets]
-
- if outputtime in datetime_to_bytelist:
- t_list = datetime_to_bytelist[outputtime]
- t_list.append(num_bytes)
- datetime_to_bytelist[outputtime] = t_list
- else :
- datetime_to_bytelist[outputtime] = [num_bytes]
- num_packets = 0
- num_bytes = 0
- tmpdeltamultiple = tmpdeltamultiple + 1
-
-timestamps = datetime_to_packetlist.keys()
-timestamps.sort()
-tmp_total = 0
-tmp_size = 0
-for time_it in timestamps:
- if len(datetime_to_packetlist[time_it]) > 1:
- mtmp = stats.mean(datetime_to_packetlist[time_it])
- vtmp = stats.var(datetime_to_packetlist[time_it])
- tmp_size = len(datetime_to_packetlist[time_it])
- tmp_total = tmp_total + tmp_size*mtmp
- packetstatsout.write( "%s %f %f %i %i\n" % \
- (time_it,mtmp,vtmp,tmp_total,tmp_size) )
- else :
- mtmp = stats.mean(datetime_to_packetlist[time_it])
- tmp_size = len(datetime_to_packetlist[time_it])
- tmp_total = tmp_total + tmp_size*mtmp
- packetstatsout.write( "%s %f -1 %i %i\n" % \
- (time_it,mtmp,tmp_total,tmp_size) )
-
- #datetime_to_packetlist[time_it]
-
-timestamps = datetime_to_bytelist.keys()
-timestamps.sort()
-tmp_total = 0
-tmp_size = 0
-for time_it in timestamps:
- if len(datetime_to_bytelist[time_it]) > 1:
- mtmp = stats.mean(datetime_to_bytelist[time_it])
- vtmp = stats.var(datetime_to_bytelist[time_it])
- tmp_size = len(datetime_to_bytelist[time_it])
- tmp_total = tmp_total + tmp_size*mtmp
- bytestatsout.write( "%s %f %f %f %i\n" % (time_it,mtmp,vtmp,tmp_total,tmp_size) )
- else :
- mtmp = stats.mean(datetime_to_bytelist[time_it])
- tmp_size = len(datetime_to_bytelist[time_it])
- tmp_total = tmp_total + tmp_size*mtmp
- bytestatsout.write( "%s %f -1 %f %i\n" % ( time_it,mtmp,tmp_total,tmp_size ) )
-
-
View
14 tests/loganalysis/rdp_plot.gnuplot
@@ -1,14 +0,0 @@
-
-
-#set xtics (0,500,1000,1500,2000,2500,3000)
-#set ytics (0,1,5,10,15,20,25,30)
-set ylabel "RDP"
-set xlabel "PING Round Trip Time (milliseconds) (50 ms bins)"
-set size 0.85
-set yrange [0:20]
-set term post eps color enhanced
-set output "RDP_figure.eps"
-
-plot 'test2.txt' using 1:3 title "Median" w l,\
-1.0 notitle w l,\
-'test2.txt' using 1:3:2:4 title "Minimum, Median, 90th Percentile" w yerrorbars
View
95 tests/loganalysis/reorder_confile.py
@@ -1,95 +0,0 @@
-#!/usr/bin/env python
-#
-# This ensures that the the deletion statements come after the regular log
-# statements for each node.
-#
-#
-#
-import sys, math, re
-from sets import Set
-from datetime import datetime , timedelta
-infilename = sys.argv[1]
-
-icfile = open( infilename, 'r') # r for reading
-outfilename = infilename + 'reordered'
-ofile = open( outfilename, 'w') # w for writing
-nodelist = []
-#parse times
-regexp = re.compile('(\d*)-(\d*)-(\d*)\W(\d*):(\d*):(\d*).(\d*)')
-
-rev_line_list = []
-for line in icfile:
- rev_line_list.insert(0,line)
-
-# time --> connection disconnection log statement list
-log_dictionary = {}
-# node --> deletion time
-deletion_time = {}
-last_log = {}
-one_sec = timedelta(seconds=1)
-
-for line in rev_line_list:
- parsed_line = line.split()
- tmp_date_time = None
- datestring = "%s %s" % (parsed_line[0],parsed_line[1])
- match = regexp.match(datestring)
- if match:
- year = int(match.group(1) )
- month = int( match.group(2) )
- day = int(match.group(3) )
- hour = int( match.group(4) )
- min = int( match.group(5) )
- sec = int( match.group(6) )
- mic = int( match.group(7) )
- tmp_date_time = datetime(year,month,day,hour,min,sec,mic)
- else:
- print "NO MATCH"
-
- if parsed_line[2] == 'deletion' :
- if parsed_line[4] not in deletion_time:
- deletion_time[parsed_line[4]] = None
- print "Added to deletion table", parsed_line[4]
- else:
- pass
- #print "ERROR- multiple deletion", parsed_line[4]
- else:
- tmp_list = []
- if tmp_date_time in log_dictionary:
- tmp_list = log_dictionary[tmp_date_time]
- tmp_list.append(line)
- log_dictionary[tmp_date_time] = tmp_list
- else:
- tmp_list.append(line)
- log_dictionary[tmp_date_time] = tmp_list
-
- l_a = parsed_line[4]
- r_a = parsed_line[5]
- #print parsed_line, l_a , r_a
- if l_a not in last_log:
- last_log[l_a] = tmp_date_time + one_sec
- if r_a not in last_log:
- last_log[r_a] = tmp_date_time + one_sec
-
-
-del_keys = deletion_time.keys()