/// <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); }
public static int Main(string [] args) { Parameters p = new Parameters("RelayOverlapSimulator", "Brunet Time Based Simulator for Relays"); if (p.Parse(args) != 0) { Console.WriteLine(p.ErrorMessage); p.ShowHelp(); return(-1); } else if (p.Help) { p.ShowHelp(); return(-1); } RelayOverlapSimulator sim = new RelayOverlapSimulator(p); sim.Complete(false); if (p.Evaluation) { Evaluator(sim); } else { Simulator(sim); } return(0); }
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 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"); }
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; }
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 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"); }
// [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 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 Relays() { Parameters p = new Parameters("Test", "Test"); string[] args = "-s=100".Split(' '); Assert.AreNotEqual(-1, p.Parse(args), "Unable to parse" + p.ErrorMessage);; RelayOverlapSimulator sim = new RelayOverlapSimulator(p); Address addr1 = null, addr2 = null; sim.AddDisconnectedPair(out addr1, out addr2, sim.NCEnable); sim.Complete(true); SimpleTimer.RunSteps(1000000, false); Node node1 = (sim.Nodes[addr1] as NodeMapping).Node as Node; Node node2 = (sim.Nodes[addr2] as NodeMapping).Node as Node; if (node1.ConnectionTable.GetConnection(ConnectionType.Structured, addr2) != null) { Relays(); return; } ManagedConnectionOverlord mco = new ManagedConnectionOverlord(node1); mco.Start(); node1.AddConnectionOverlord(mco); mco.Set(addr2); sim.Complete(true); SimpleTimer.RunSteps(100000, false); Assert.IsTrue(node1.ConnectionTable.GetConnection(ConnectionType.Structured, addr2) != null); foreach (Connection con in node1.ConnectionTable.GetConnections(Relay.OverlapConnectionOverlord.STRUC_OVERLAP)) { con.Edge.Close(); } foreach (Connection con in node2.ConnectionTable.GetConnections(Relay.OverlapConnectionOverlord.STRUC_OVERLAP)) { con.Edge.Close(); } SimpleTimer.RunSteps(100000, false); Assert.IsTrue(node1.ConnectionTable.GetConnection(ConnectionType.Structured, addr2) != null); sim.Disconnect(); }
public void Relays() { Parameters p = new Parameters("Test", "Test"); string[] args = "-s=100".Split(' '); Assert.AreNotEqual(-1, p.Parse(args), "Unable to parse" + p.ErrorMessage); RelayOverlapSimulator sim = new RelayOverlapSimulator(p); _sim = sim; Address addr1 = null, addr2 = null; Node node1 = null, node2 = null; while (true) { sim.AddDisconnectedPair(out addr1, out addr2, sim.NCEnable); sim.Complete(true); node1 = (sim.Nodes[addr1] as NodeMapping).Node as Node; node2 = (sim.Nodes[addr2] as NodeMapping).Node as Node; if (!Simulator.AreConnected(node1, node2)) { break; } } ManagedConnectionOverlord mco = new ManagedConnectionOverlord(node1); mco.Start(); node1.AddConnectionOverlord(mco); mco.Set(addr2); Assert.IsTrue(AreConnected(node1, node2)); foreach (Connection con in node1.ConnectionTable.GetConnections(Relay.OverlapConnectionOverlord.STRUC_OVERLAP)) { con.State.Edge.Close(); } foreach (Connection con in node2.ConnectionTable.GetConnections(Relay.OverlapConnectionOverlord.STRUC_OVERLAP)) { con.State.Edge.Close(); } Assert.IsTrue(Simulator.AreConnected(node1, node2)); }
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 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 void Relays() { Parameters p = new Parameters("Test", "Test"); string[] args = "-s=100".Split(' '); Assert.AreNotEqual(-1, p.Parse(args), "Unable to parse" + p.ErrorMessage);; RelayOverlapSimulator sim = new RelayOverlapSimulator(p); Address addr1 = null, addr2 = null; sim.AddDisconnectedPair(out addr1, out addr2, sim.NCEnable); sim.Complete(true); SimpleTimer.RunSteps(1000000, false); Node node1 = (sim.Nodes[addr1] as NodeMapping).Node as Node; Node node2 = (sim.Nodes[addr2] as NodeMapping).Node as Node; if(node1.ConnectionTable.GetConnection(ConnectionType.Structured, addr2) != null) { Relays(); return; } ManagedConnectionOverlord mco = new ManagedConnectionOverlord(node1); mco.Start(); node1.AddConnectionOverlord(mco); mco.Set(addr2); sim.Complete(true); SimpleTimer.RunSteps(100000, false); Assert.IsTrue(node1.ConnectionTable.GetConnection(ConnectionType.Structured, addr2) != null); foreach(Connection con in node1.ConnectionTable.GetConnections(Relay.OverlapConnectionOverlord.STRUC_OVERLAP)) { con.Edge.Close(); } foreach(Connection con in node2.ConnectionTable.GetConnections(Relay.OverlapConnectionOverlord.STRUC_OVERLAP)) { con.Edge.Close(); } SimpleTimer.RunSteps(100000, false); Assert.IsTrue(node1.ConnectionTable.GetConnection(ConnectionType.Structured, addr2) != null); sim.Disconnect(); }
public static int Main(string []args) { Parameters p = new Parameters("RelayOverlapSimulator", "Brunet Time Based Simulator for Relays"); if(p.Parse(args) != 0) { Console.WriteLine(p.ErrorMessage); p.ShowHelp(); return -1; } else if(p.Help) { p.ShowHelp(); return -1; } RelayOverlapSimulator sim = new RelayOverlapSimulator(p); sim.Complete(false); if(p.Evaluation) { Evaluator(sim); } else { Simulator(sim); } return 0; }
public void Relays() { Parameters p = new Parameters("Test", "Test"); string[] args = "-s=100".Split(' '); Assert.AreNotEqual(-1, p.Parse(args), "Unable to parse" + p.ErrorMessage); RelayOverlapSimulator sim = new RelayOverlapSimulator(p); _sim = sim; Address addr1 = null, addr2 = null; Node node1 = null, node2 = null; while(true) { sim.AddDisconnectedPair(out addr1, out addr2, sim.NCEnable); sim.Complete(true); node1 = (sim.Nodes[addr1] as NodeMapping).Node as Node; node2 = (sim.Nodes[addr2] as NodeMapping).Node as Node; if(!Simulator.AreConnected(node1, node2)) { break; } } ManagedConnectionOverlord mco = new ManagedConnectionOverlord(node1); mco.Start(); node1.AddConnectionOverlord(mco); mco.Set(addr2); Assert.IsTrue(AreConnected(node1, node2)); foreach(Connection con in node1.ConnectionTable.GetConnections(Relay.OverlapConnectionOverlord.STRUC_OVERLAP)) { con.Edge.Close(); } foreach(Connection con in node2.ConnectionTable.GetConnections(Relay.OverlapConnectionOverlord.STRUC_OVERLAP)) { con.Edge.Close(); } Assert.IsTrue(Simulator.AreConnected(node1, node2)); }