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); } } }
/// <summary>Create a new node in the public overlay and a matching one in /// the private overlay.</summary> override public Node AddNode() { Node snode = _shared_overlay.AddNode(); NodeMapping snm = _shared_overlay.Nodes[snode.Address]; // Must do this to remove it after successfully creating the new node Node.StateChangeHandler add_node = null; // Delayed add, removes ~15 seconds off bootstrapping time add_node = delegate(Node n, Node.ConnectionState cs) { if (cs != Node.ConnectionState.Connected) { return; } snm.Node.StateChangeEvent -= add_node; Node node = AddNode(snm.ID, snode.Address as AHAddress); EdgeListener el = new SubringEdgeListener(snode, node); if (_secure_edges) { NodeMapping pnm = Nodes[node.Address] as NodeMapping; el = new SecureEdgeListener(el, pnm.SO); } node.AddEdgeListener(el); node.AddTADiscovery(new DhtDiscovery(node as StructuredNode, snm.Dht, snm.Node.Realm, snm.DhtProxy)); CurrentNetworkSize--; }; // Check will return true, since the Node is unregistered CurrentNetworkSize++; snm.Node.StateChangeEvent += add_node; return(snode); }
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); }
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 Commands(Simulator sim) { string command = String.Empty; Console.WriteLine("Type HELP for a list of commands.\n"); while (command != "Q") { bool secure = false; Console.Write("#: "); // Commands can have parameters separated by spaces string[] parts = Console.ReadLine().Split(' '); command = parts[0]; try { if(command.Equals("S")) { secure = true; command = parts[1]; } switch(command) { case "C": sim.CheckRing(true); break; case "P": sim.PrintConnections(); break; case "M": Console.WriteLine("Memory Usage: " + GC.GetTotalMemory(true)); break; case "CR": sim.Crawl(true, secure); break; case "A2A": sim.AllToAll(secure); break; case "A": sim.AddNode(); break; case "D": sim.RemoveNode(true, true); break; case "R": sim.RemoveNode(true, false); break; case "RUN": int steps = (parts.Length >= 2) ? Int32.Parse(parts[1]) : 0; if(steps > 0) { SimpleTimer.RunSteps(steps); } else { SimpleTimer.RunStep(); } break; case "Q": break; case "CONSTATE": sim.PrintConnectionState(); break; case "H": Console.WriteLine("Commands: \n"); Console.WriteLine("A - add a node"); Console.WriteLine("D - remove a node"); Console.WriteLine("R - abort 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("[S] CR - Perform a (secure) crawl of the network using RPC"); Console.WriteLine("[S] A2A - Perform all-to-all measurement of the network using RPC"); Console.WriteLine("Q - Quit"); break; default: Console.WriteLine("Invalid command"); break; } } catch(Exception e) { Console.WriteLine("Error: " + e); } Console.WriteLine(); } }
public static void Commands(Simulator sim) { string command = String.Empty; Console.WriteLine("Type HELP for a list of commands.\n"); while (command != "Q") { bool secure = false; Console.Write("#: "); // Commands can have parameters separated by spaces string[] parts = Console.ReadLine().Split(' '); command = parts[0]; try { if (command.Equals("S")) { secure = true; command = parts[1]; } switch (command) { case "C": sim.CheckRing(true); break; case "P": sim.PrintConnections(); break; case "M": Console.WriteLine("Memory Usage: " + GC.GetTotalMemory(true)); break; case "CR": sim.Crawl(true, secure); break; case "A2A": sim.AllToAll(secure); break; case "A": sim.AddNode(); break; case "D": sim.RemoveNode(true, true); break; case "R": sim.RemoveNode(true, false); break; case "RUN": int steps = (parts.Length >= 2) ? Int32.Parse(parts[1]) : 0; if (steps > 0) { SimpleTimer.RunSteps(steps); } else { SimpleTimer.RunStep(); } break; case "Q": break; case "CONSTATE": sim.PrintConnectionState(); break; case "H": Console.WriteLine("Commands: \n"); Console.WriteLine("A - add a node"); Console.WriteLine("D - remove a node"); Console.WriteLine("R - abort 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("[S] CR - Perform a (secure) crawl of the network using RPC"); Console.WriteLine("[S] A2A - Perform all-to-all measurement of the network using RPC"); Console.WriteLine("Q - Quit"); break; default: Console.WriteLine("Invalid command"); break; } } catch (Exception e) { Console.WriteLine("Error: " + e); } Console.WriteLine(); } }
public static void ParseCommandLine(string []args, out bool complete, Simulator sim) { complete = false; string dataset_filename = String.Empty; int carg = 0; sim.StartingNetworkSize = 10; while(carg < args.Length) { String[] parts = args[carg++].Split('='); try { switch(parts[0]) { case "--n": sim.StartingNetworkSize = Int32.Parse(parts[1]); break; case "--broken": sim.Broken = Double.Parse(parts[1]); break; case "--complete": complete = true; break; case "--seed": sim.Seed = Int32.Parse(parts[1]); break; case "--se": sim.SecureEdges = true; sim.SecureStartup(); break; case "--ss": sim.SecureSenders = true; sim.SecureStartup(); break; case "--dataset": dataset_filename = parts[1]; break; case "--help": default: PrintHelp(); break; } } catch { PrintHelp(); } } Console.WriteLine("Initializing..."); if(dataset_filename != String.Empty) { List<List<int>> latency = new List<List<int>>(); using(StreamReader fs = new StreamReader(new FileStream(dataset_filename, FileMode.Open))) { string line = null; while((line = fs.ReadLine()) != null) { string[] points = line.Split(' '); List<int> current = new List<int>(points.Length); foreach(string point in points) { int val; if(!Int32.TryParse(point, out val)) { continue; } current.Add(Int32.Parse(point)); } latency.Add(current); } } if(sim.StartingNetworkSize == 10) { sim.StartingNetworkSize = latency.Count; } SimulationEdgeListener.LatencyMap = latency; } for(int i = 0; i < sim.StartingNetworkSize; i++) { Console.WriteLine("Setting up node: " + i); sim.AddNode(); } Console.WriteLine("Initialization complete...\n"); }
public static void Commands(Simulator sim) { string command = String.Empty; Console.WriteLine("Type HELP for a list of commands.\n"); while (command != "Q") { bool secure = false; Console.Write("#: "); // Commands can have parameters separated by spaces string[] parts = Console.ReadLine().Split(' '); command = parts[0].ToUpper(); try { if (command.Equals("S")) { secure = true; command = parts[1].ToUpper();; } switch (command) { case "B": int forwarders = (parts.Length >= 2) ? Int32.Parse(parts[1]) : -1; Broadcast bcast = new Broadcast(sim.SimBroadcastHandler, sim.RandomNode().Node, forwarders, TaskFinished); bcast.Start(); RunUntilTaskFinished(); break; case "C": sim.CheckRing(true); break; case "P": sim.PrintConnections(); break; case "M": Console.WriteLine("Memory Usage: " + GC.GetTotalMemory(true)); break; case "CR": NodeMapping nm = sim.Nodes.Values[0]; SymphonySecurityOverlord bso = null; if (secure) { bso = nm.Sso; } Crawl c = new Crawl(nm.Node, sim.Nodes.Count, bso, TaskFinished); c.Start(); RunUntilTaskFinished(); break; case "A2A": AllToAll atoa = new AllToAll(sim.Nodes, secure, TaskFinished); atoa.Start(); RunUntilTaskFinished(); break; case "A": sim.AddNode(); break; case "D": sim.RemoveNode(true, true); break; case "R": sim.RemoveNode(false, true); break; case "REVOKE": sim.Revoke(true); break; case "RUN": int steps = (parts.Length >= 2) ? Int32.Parse(parts[1]) : 0; if (steps > 0) { SimpleTimer.RunSteps(steps); } else { SimpleTimer.RunStep(); } break; case "Q": break; case "CONSTATE": sim.PrintConnectionState(); break; case "H": Console.WriteLine("Commands: \n"); Console.WriteLine("A - add a node"); Console.WriteLine("D - remove a node"); Console.WriteLine("R - abort 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("[S] CR - Perform a (secure) crawl of the network using RPC"); Console.WriteLine("[S] A2A - Perform all-to-all measurement of the network using RPC"); Console.WriteLine("Q - Quit"); break; default: Console.WriteLine("Invalid command"); break; } } catch (Exception e) { Console.WriteLine("Error: " + e); } Console.WriteLine(); } }
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); } }
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(); }