public static void HeavyChurn(Simulator sim, int time) { sim.Complete(); Dictionary<Node, Node> volatile_nodes = new Dictionary<Node, Node>(); int fifteen_mins = (int) ((new TimeSpan(0, 15, 0)).Ticks / TimeSpan.TicksPerMillisecond); int max = sim.StartingNetworkSize * 2; Random rand = new Random(); DateTime end = DateTime.UtcNow.AddSeconds(time); while(end > DateTime.UtcNow) { SimpleTimer.RunSteps(fifteen_mins); List<Node> to_remove = new List<Node>(); foreach(Node node in volatile_nodes.Keys) { double prob = rand.NextDouble(); if(prob <= .7) { continue; } // This is due to some bug that I can no longer remember // sim.RemoveNode(node, prob > .9); sim.RemoveNode(node, true); to_remove.Add(node); } foreach(Node node in to_remove) { volatile_nodes.Remove(node); } Console.WriteLine("Removed: {0} Nodes" , to_remove.Count); while(volatile_nodes.Count < max) { Node node = sim.AddNode(); volatile_nodes.Add(node, node); } } }
public static int Main(string []args) { Parameters p = new Parameters("Simulator", "Simulator - Brunet Time Based Simulator"); if(p.Parse(args) != 0) { Console.WriteLine(p.ErrorMessage); p.ShowHelp(); return -1; } else if(p.Help) { p.ShowHelp(); return -1; } Simulator sim = new Simulator(p); if(p.Complete) { sim.Complete(); } else if(p.Evaluation) { DateTime now = DateTime.UtcNow; sim.Complete(); SimpleTimer.RunSteps(p.EvaluationTime, false); sim.Complete(); Console.WriteLine("Time spent setting up: " + (DateTime.UtcNow - now).ToString()); sim.AllToAll(); sim.Crawl(); } else if(p.HeavyChurn) { HeavyChurn(sim, p.EvaluationTime); } else { Commands(sim); } return 0; }
protected static void Evaluate(Simulator sim, Parameters p) { // DateTime now = DateTime.UtcNow; SimpleTimer.RunSteps(360000, false); sim.Complete(true); SimpleTimer.RunSteps(3600000, false); sim.Complete(true); sim.AddNode(); sim.Complete(false); }
protected static void Broadcast(Simulator sim, int forwarders) { DateTime now = DateTime.UtcNow; SimpleTimer.RunSteps(360000, false); sim.Complete(true); SimpleTimer.RunSteps(3600000, false); sim.Complete(true); Console.WriteLine("Time spent setting up: " + (DateTime.UtcNow - now).ToString()); for(int i = 0; i < sim.Nodes.Count; i++) { sim.Broadcast(i, forwarders); } }
public void CompleteTheRing() { Parameters p = new Parameters("Test", "Test"); string[] args = "-b=.2 -c -s=250".Split(' '); p.Parse(args); Simulator sim = new Simulator(p); Assert.IsTrue(sim.Complete(true), "Simulation failed to complete the ring"); }
public void CompleteTheRing() { Parameters p = new Parameters("Test", "Test"); string[] args = "-b=.2 -c -s=25".Split(' '); Assert.AreNotEqual(-1, p.Parse(args), "Unable to parse" + p.ErrorMessage);; Simulator sim = new Simulator(p); Assert.IsTrue(sim.Complete(true), "Simulation failed to complete the ring"); }
private void TestNat(Simulator sim, NatTypes n0type0, NatTypes n0type1, NatTypes n1type0, NatTypes n1type1, bool relay) { string fail_s = String.Format("{0}/{1} and {2}/{3}", n0type0, n0type1, n1type0, n1type1); Node node0 = null; Node node1 = null; while (true) { node0 = NatFactory.AddNode(sim, n0type0, n0type1, relay); node1 = NatFactory.AddNode(sim, n1type0, n1type1, relay); Assert.IsTrue(sim.Complete(true), fail_s + " nodes are connected to the overlay"); if (!Simulator.AreConnected(node0, node1)) { break; } } ManagedConnectionOverlord mco = new ManagedConnectionOverlord(node0); mco.Start(); node0.AddConnectionOverlord(mco); mco.Set(node1.Address); Assert.IsTrue(AreConnected(node0, node1), fail_s + " nodes were unable to connect."); }
public void SecureRingTest() { Parameters p = new Parameters("Test", "Test"); string[] args = "-b=.2 -c --secure_edges -s=25".Split(' '); Assert.AreNotEqual(-1, p.Parse(args), "Unable to parse" + p.ErrorMessage); Simulator sim = new Simulator(p); _sim = sim; Assert.IsTrue(sim.Complete(true), "Simulation failed to complete the ring"); var nm0 = sim.TakenIDs.Values[0]; int idx = 1; NodeMapping nm1 = null; do { nm1 = sim.TakenIDs.Values[idx++]; } while(Simulator.AreConnected(nm0.Node, nm1.Node) && idx < sim.TakenIDs.Count); Assert.IsFalse(Simulator.AreConnected(nm0.Node, nm1.Node), "Sanity check"); var ptype = new PType("chtest"); var ch0 = new ConnectionHandler(ptype, (StructuredNode)nm0.Node); var ch1 = new ConnectionHandler(ptype, (StructuredNode)nm1.Node); ConnectionHandlerTest(nm0.Node, nm1.Node, ch0, ch1); }
public static int Main(string []args) { #if SUBRING SubringParameters p = new SubringParameters(); #else Parameters p = new Parameters("Simulator", "Simulator - Brunet Time Based Simulator"); #endif if(p.Parse(args) != 0) { Console.WriteLine(p.ErrorMessage); p.ShowHelp(); return -1; } else if(p.Help) { p.ShowHelp(); return -1; } #if SUBRING SubringSimulator sim = new SubringSimulator(p); #else Simulator sim = new Simulator(p); #endif if(p.Complete) { sim.Complete(); } else if(p.Broadcast > -2) { Broadcast(sim, p.Broadcast); } else if(p.HeavyChurn > 0) { HeavyChurn(sim, p.HeavyChurn); } else if(p.Evaluation) { Evaluate(sim, p); } else { Commands(sim); } return 0; }
/// <summary>First half builds the ring, second half tests the connection handler...</summary> public void RingTest() { Parameters p = new Parameters("Test", "Test"); string[] args = "-b=.2 -c --secure_senders -s=50".Split(' '); Assert.AreNotEqual(-1, p.Parse(args), "Unable to parse" + p.ErrorMessage); Simulator sim = new Simulator(p); _sim = sim; Assert.IsTrue(sim.Complete(true), "Simulation failed to complete the ring"); SimpleTimer.RunSteps(fifteen_mins, false); var nm0 = sim.TakenIDs.Values[0]; int idx = 1; NodeMapping nm1 = null; do { nm1 = sim.TakenIDs.Values[idx++]; } while(Simulator.AreConnected(nm0.Node, nm1.Node) && idx < sim.TakenIDs.Count); Assert.IsFalse(Simulator.AreConnected(nm0.Node, nm1.Node), "Sanity check"); var ptype = new PType("chtest"); var ch0 = new ConnectionHandler(ptype, (StructuredNode) nm0.Node); var ch1 = new ConnectionHandler(ptype, (StructuredNode) nm1.Node); ConnectionHandlerTest(nm0.Node, nm1.Node, ch0, ch1); SimpleTimer.RunSteps(fifteen_mins * 2, false); Assert.IsFalse(Simulator.AreConnected(nm0.Node, nm1.Node), "Sanity check0"); ptype = new PType("chtest1"); ch0 = new SecureConnectionHandler(ptype, (StructuredNode) nm0.Node, nm0.Sso); ch1 = new SecureConnectionHandler(ptype, (StructuredNode) nm1.Node, nm1.Sso); ConnectionHandlerTest(nm0.Node, nm1.Node, ch0, ch1); }
protected static void Broadcast(Simulator sim, int forwarders, string filename) { DateTime now = DateTime.UtcNow; SimpleTimer.RunSteps(360000, false); sim.Complete(true); SimpleTimer.RunSteps(3600000, false); sim.Complete(true); Console.WriteLine("Time spent setting up: " + (DateTime.UtcNow - now).ToString()); for (int i = 0; i < sim.Nodes.Count; i++) { Broadcast bcast = new Broadcast(sim.SimBroadcastHandler, sim.Nodes.Values[i].Node, forwarders, TaskFinished); bcast.Start(); RunUntilTaskFinished(); bcast.WriteResultsToDisk(filename); } }
// [Test] public void CompleteTheDtlsRing() { Parameters p = new Parameters("Test", "Test"); string[] args = "-b=.2 --dtls -c --secure_edges -s=25".Split(' '); Assert.AreNotEqual(-1, p.Parse(args), "Unable to parse" + p.ErrorMessage); Simulator sim = new Simulator(p); Assert.IsTrue(sim.Complete(true), "Simulation failed to complete the ring"); }
public void CompleteTheRing() { Parameters p = new Parameters("Test", "Test"); string[] args = "-b=.2 -c -s=250".Split(' '); p.Parse(args); Simulator sim = new Simulator(p); Assert.IsTrue(sim.Complete(true), "Simulation failed to complete the ring"); }
public static int Main(string [] args) { Parameters p = new Parameters("Simulator", "Simulator - Brunet Time Based Simulator"); if (p.Parse(args) != 0) { Console.WriteLine(p.ErrorMessage); p.ShowHelp(); return(-1); } else if (p.Help) { p.ShowHelp(); return(-1); } Simulator sim = new Simulator(p); if (p.Complete) { sim.Complete(); } else if (p.Evaluation) { DateTime now = DateTime.UtcNow; sim.Complete(); SimpleTimer.RunSteps(p.EvaluationTime, false); sim.Complete(); Console.WriteLine("Time spent setting up: " + (DateTime.UtcNow - now).ToString()); sim.AllToAll(); sim.Crawl(); } else if (p.HeavyChurn) { HeavyChurn(sim, p.EvaluationTime); } else { Commands(sim); } return(0); }
public static void Main(string []args) { Simulator sim = new Simulator(); bool complete = false; ParseCommandLine(args, out complete, sim); if(complete) { sim.Complete(); } else { Commands(sim); } }
protected static void Evaluate(Simulator sim, Parameters p) { // DateTime now = DateTime.UtcNow; SimpleTimer.RunSteps(360000, false); sim.Complete(true); SimpleTimer.RunSteps(3600000, false); sim.Complete(true); sim.AddNode(); sim.Complete(false); // Console.WriteLine("Time spent setting up: " + (DateTime.UtcNow - now).ToString()); // sim.AllToAll(); // sim.Crawl(); }
public static int Main(string [] args) { #if SUBRING SubringParameters p = new SubringParameters(); #else Parameters p = new Parameters("Simulator", "Simulator - Brunet Time Based Simulator"); #endif if (p.Parse(args) != 0) { Console.WriteLine(p.ErrorMessage); p.ShowHelp(); return(-1); } else if (p.Help) { p.ShowHelp(); return(-1); } #if SUBRING SubringSimulator sim = new SubringSimulator(p); #else Simulator sim = new Simulator(p); #endif if (p.Complete) { sim.Complete(false); } else if (p.Broadcast > -2) { Broadcast(sim, p.Broadcast, p.Output); } else if (p.HeavyChurn > 0) { HeavyChurn(sim, p.HeavyChurn); } else if (p.Evaluation) { Evaluate(sim, p); } else { Commands(sim); } return(0); }
public void TestNatTraversal() { Parameters p = new Parameters("Test", "Test"); string[] args = "-c -s=100".Split(' '); Assert.AreNotEqual(-1, p.Parse(args), "Unable to parse" + p.ErrorMessage); Simulator sim = new Simulator(p); _sim = sim; Assert.IsTrue(sim.Complete(true), "Simulation failed to complete the ring"); SimpleTimer.RunSteps(1000000, false); TestNat(sim, NatTypes.Cone, NatTypes.Disabled, false); TestNat(sim, NatTypes.RestrictedCone, NatTypes.Disabled, false); TestNat(sim, NatTypes.Symmetric, NatTypes.Disabled, true); TestNat(sim, NatTypes.Symmetric, NatTypes.Disabled, NatTypes.RestrictedCone, NatTypes.Disabled, false); TestNat(sim, NatTypes.Symmetric, NatTypes.OutgoingOnly, true); }
public void SecureRingTest() { Parameters p = new Parameters("Test", "Test"); string[] args = "-b=.2 -c --secure_edges -s=25".Split(' '); Assert.AreNotEqual(-1, p.Parse(args), "Unable to parse" + p.ErrorMessage); Simulator sim = new Simulator(p); _sim = sim; Assert.IsTrue(sim.Complete(true), "Simulation failed to complete the ring"); var nm0 = sim.TakenIDs.Values[0]; int idx = 1; var nm1 = sim.TakenIDs.Values[idx]; while(Simulator.AreConnected(nm0.Node, nm1.Node) && idx < sim.TakenIDs.Count) { nm1 = sim.TakenIDs.Values[++idx]; } var ptype = new PType("chtest"); var ch0 = new SecureConnectionHandler(ptype, (StructuredNode) nm0.Node, nm0.Sso); var ch1 = new SecureConnectionHandler(ptype, (StructuredNode) nm1.Node, nm1.Sso); ConnectionHandlerTest(nm0.Node, nm1.Node, ch0, ch1); }
/// <summary>First half builds the ring, second half tests the connection handler...</summary> public void RingTest() { Parameters p = new Parameters("Test", "Test"); string[] args = "-b=.2 -c -s=50".Split(' '); Assert.AreNotEqual(-1, p.Parse(args), "Unable to parse" + p.ErrorMessage); Simulator sim = new Simulator(p); _sim = sim; Assert.IsTrue(sim.Complete(true), "Simulation failed to complete the ring"); SimpleTimer.RunSteps(fifteen_mins); Node node0 = sim.TakenIDs.Values[0].Node; int idx = 1; Node node1 = sim.TakenIDs.Values[idx].Node; while(Simulator.AreConnected(node0, node1) && idx < sim.TakenIDs.Count) { node1 = sim.TakenIDs.Values[++idx].Node; } var ptype = new PType("chtest"); var ch0 = new ConnectionHandler(ptype, (StructuredNode) node0); var ch1 = new ConnectionHandler(ptype, (StructuredNode) node1); ConnectionHandlerTest(node0, node1, ch0, ch1); }
public static void HeavyChurn(Simulator sim, int time) { sim.Complete(); Dictionary <Node, Node> volatile_nodes = new Dictionary <Node, Node>(); int fifteen_mins = (int)((new TimeSpan(0, 15, 0)).Ticks / TimeSpan.TicksPerMillisecond); int max = sim.StartingNetworkSize * 2; Random rand = new Random(); DateTime end = DateTime.UtcNow.AddSeconds(time); while (end > DateTime.UtcNow) { SimpleTimer.RunSteps(fifteen_mins); List <Node> to_remove = new List <Node>(); foreach (Node node in volatile_nodes.Keys) { double prob = rand.NextDouble(); if (prob <= .7) { continue; } // This is due to some bug that I can no longer remember // sim.RemoveNode(node, prob > .9); sim.RemoveNode(node, true); to_remove.Add(node); } foreach (Node node in to_remove) { volatile_nodes.Remove(node); } Console.WriteLine("Removed: {0} Nodes", to_remove.Count); while (volatile_nodes.Count < max) { Node node = sim.AddNode(); volatile_nodes.Add(node, node); } } }
public static void Main(string []args) { Simulator sim = new Simulator(); bool complete; Runner.ParseCommandLine(args, out complete, sim); DateTime start = DateTime.UtcNow; sim.Complete(); Dictionary<Node, Node> volatile_nodes = new Dictionary<Node, Node>(); int fifteen_mins = (int) ((new TimeSpan(0, 15, 0)).Ticks / TimeSpan.TicksPerMillisecond); int max = sim.StartingNetworkSize * 10; Random rand = new Random(); while(start.AddHours(24) > DateTime.UtcNow) { SimpleTimer.RunSteps(fifteen_mins); List<Node> to_remove = new List<Node>(); foreach(Node node in volatile_nodes.Keys) { double prob = rand.NextDouble(); if(prob <= .7) { continue; } // sim.RemoveNode(node, prob > .9); sim.RemoveNode(node, true); to_remove.Add(node); } foreach(Node node in to_remove) { volatile_nodes.Remove(node); } Console.WriteLine("Removed: {0} Nodes" , to_remove.Count); while(volatile_nodes.Count < max) { Node node = sim.AddNode(); volatile_nodes.Add(node, node); } } }
public static void Run(Simulator sim, Address addr1, Address addr2) { Console.WriteLine("Beginning"); sim.Complete(); SimpleTimer.RunSteps(1000000, false); StructuredNode node1 = (sim.Nodes[addr1] as NodeMapping).Node as StructuredNode; StructuredNode node2 = (sim.Nodes[addr2] as NodeMapping).Node as StructuredNode; sim.Complete(); node1.ManagedCO.AddAddress(addr2); Connection con1 = node1.ConnectionTable.GetConnection(ConnectionType.Structured, addr2); while(con1 == null) { SimpleTimer.RunStep(); con1 = node1.ConnectionTable.GetConnection(ConnectionType.Structured, addr2); } Hashtable ht = new Hashtable(); foreach(Connection con in node1.ConnectionTable.GetConnections(Tunnel.OverlapConnectionOverlord.STRUC_OVERLAP)) { ht[con.Address] = (con.Edge as SimulationEdge).Delay; con.Edge.Close(); } ConnectionList cl2 = node2.ConnectionTable.GetConnections(ConnectionType.Structured); foreach(DictionaryEntry de in ht) { Address addr = de.Key as Address; int delay = (int) de.Value; int index = cl2.IndexOf(addr); if(index < 0) { Console.WriteLine("No matching pair for overlap..."); continue; } Connection con = cl2[index]; delay += (con.Edge as SimulationEdge).Delay; Console.WriteLine("Delay: " + delay); } ht.Clear(); foreach(Connection con in node2.ConnectionTable.GetConnections(Tunnel.OverlapConnectionOverlord.STRUC_OVERLAP)) { ht[con.Address] = (con.Edge as SimulationEdge).Delay; con.Edge.Close(); } ConnectionList cl1 = node1.ConnectionTable.GetConnections(ConnectionType.Structured); foreach(DictionaryEntry de in ht) { Address addr = de.Key as Address; int delay = (int) de.Value; int index = cl1.IndexOf(addr); if(index < 0) { Console.WriteLine("No matching pair for overlap..."); continue; } Connection con = cl1[index]; delay += (con.Edge as SimulationEdge).Delay; Console.WriteLine("Delay: " + delay); } node1.Disconnect(); node2.Disconnect(); SimpleTimer.RunSteps(100000); Console.WriteLine("End"); }
private void TestNat(Simulator sim, NatTypes n0type0, NatTypes n0type1, NatTypes n1type0, NatTypes n1type1, bool relay) { string fail_s = String.Format("{0}/{1} and {2}/{3}", n0type0, n0type1, n1type0, n1type1); Node node0 = null; Node node1 = null; while(true) { node0 = NatFactory.AddNode(sim, n0type0, n0type1, relay); node1 = NatFactory.AddNode(sim, n1type0, n1type1, relay); Assert.IsTrue(sim.Complete(true), fail_s + " nodes are connected to the overlay"); if(!Simulator.AreConnected(node0, node1)) { break; } } ManagedConnectionOverlord mco = new ManagedConnectionOverlord(node0); mco.Start(); node0.AddConnectionOverlord(mco); mco.Set(node1.Address); Assert.IsTrue(AreConnected(node0, node1), fail_s + " nodes were unable to connect."); }
public void TestNatTraversal() { Parameters p = new Parameters("Test", "Test"); string[] args = "-c -s=100".Split(' '); Assert.AreNotEqual(-1, p.Parse(args), "Unable to parse" + p.ErrorMessage); Simulator sim = new Simulator(p); _sim = sim; Assert.IsTrue(sim.Complete(true), "Simulation failed to complete the ring"); SimpleTimer.RunSteps(1000000, false); TestNat(sim, NatTypes.Cone, NatTypes.Disabled, false); TestNat(sim, NatTypes.RestrictedCone, NatTypes.Disabled, false); TestNat(sim, NatTypes.Symmetric, NatTypes.Disabled, true); TestNat(sim, NatTypes.Symmetric, NatTypes.Disabled, NatTypes.RestrictedCone, NatTypes.Disabled, false); TestNat(sim, NatTypes.Symmetric, NatTypes.OutgoingOnly, true); }
public static void HeavyChurn(Simulator sim, int time) { sim.Complete(false); Dictionary <Node, Node> volatile_nodes = new Dictionary <Node, Node>(); int fifteen_mins = (int)((new TimeSpan(0, 15, 0)).Ticks / TimeSpan.TicksPerMillisecond); int max = sim.StartingNetworkSize * 2; Random rand = new Random(); DateTime end = DateTime.UtcNow.AddSeconds(time); List <Node> to_disconnect = new List <Node>(); List <Node> to_abort = new List <Node>(); while (end > DateTime.UtcNow) { SimpleTimer.RunSteps(fifteen_mins); foreach (Node node in volatile_nodes.Keys) { double prob = rand.NextDouble(); if (prob <= .7) { continue; } if (prob > .9) { to_disconnect.Add(node); } else { to_abort.Add(node); } } int added = 0; int removed = to_disconnect.Count + to_abort.Count; while (volatile_nodes.Count < max + removed) { added++; Node node = sim.AddNode(); volatile_nodes.Add(node, node); } foreach (Node node in to_disconnect) { sim.RemoveNode(node, true, false); volatile_nodes.Remove(node); } to_disconnect.Clear(); foreach (Node node in to_abort) { // This is due to bugs in Abort don't handle closing of ELs and maybe other stuff // sim.RemoveNode(node, false, false); sim.RemoveNode(node, true, false); volatile_nodes.Remove(node); } to_abort.Clear(); Console.WriteLine("Nodes: Added: {0}, Removed: {1}", added, removed); } }