public static void traverseDoD(NetworkGraph g) { //starting at 721 print out providers to DoD people. AsNode DoDMain = g.GetNode(721); List <UInt32> DoDProviders = new List <UInt32>(); List <UInt32> DoDPeers = new List <UInt32>(); List <UInt32> DoDASNs = new List <UInt32>(); Queue <UInt32> ASesToProcess = new Queue <UInt32>(); DoDASNs.Add(721); ASesToProcess.Enqueue(721); while (ASesToProcess.Count > 0) { AsNode curr = g.GetNode(ASesToProcess.Dequeue()); Console.WriteLine("Processing: " + curr.NodeNum); foreach (var provider in curr.GetNeighborsByType(RelationshipType.CustomerOf)) { if (!DoDASNs.Contains(provider.NodeNum) && !DoDProviders.Contains(provider.NodeNum)) { DoDProviders.Add(provider.NodeNum); Console.WriteLine(curr.NodeNum + " has non-DoD provider: " + provider.NodeNum); Console.ReadLine(); } } foreach (var customer in curr.GetNeighborsByType(RelationshipType.ProviderTo)) { if (!DoDASNs.Contains(customer.NodeNum) && !ASesToProcess.Contains(customer.NodeNum)) { ASesToProcess.Enqueue(customer.NodeNum); DoDASNs.Add(customer.NodeNum); } } foreach (var peer in curr.GetNeighborsByType(RelationshipType.PeerOf)) { if (!DoDASNs.Contains(peer.NodeNum)) { DoDPeers.Add(peer.NodeNum); } } } Console.WriteLine("DoDProviders: "); foreach (var provider in DoDProviders) { if (!DoDASNs.Contains(provider)) { Console.Write(provider + ", "); } } Console.WriteLine(); Console.WriteLine("DoDPeers: "); foreach (var peer in DoDPeers) { Console.Write(peer + ", "); } Console.WriteLine(); }
public static void trafficThroughSecureProviders(resultObject results) { //get what the simulation state would look like. GlobalState GS = SimulatorLibrary.initGlobalState(results.g, results.earlyAdopters, results.weightedNodes, short.Parse(results.k)); /** First, get a list of multihomed stubs as destinations **/ var stubs = results.g.getStubs(); List <Destination> multihomedStubs = new List <Destination>(); foreach (UInt32 stubNum in stubs) { AsNode stub = results.g.GetNode(stubNum); if (stub.GetNeighborsByType(RelationshipType.CustomerOf).ToArray().Length > 1) { multihomedStubs.Add(new Destination(SimulatorLibrary.initMiniDestination(results.g, stub.NodeNum, true))); } } Console.WriteLine(multihomedStubs.Count + " stubs out of " + stubs.Count + " are multihomed."); /** Second, go through each iteration... **/ int iteration = 0; foreach (bool[] S in results.state) { DateTime IterationStart = DateTime.Now; Int32 finishedDests = 0; foreach (Destination multihomedStub in multihomedStubs) { /** for this multhomed stub, see how much traffic * goes through secure providers **/ multihomedStub.UpdatePaths(S); multihomedStub.ComputeU(GS.W); var Providers = results.g.GetNode(multihomedStub.destination).GetNeighborsByType(RelationshipType.CustomerOf); Int64 TotalU = 0; Int64 SecureProviderU = 0; Int32 TotalProviders = Providers.Count(); Int32 SecureProviders = 0; foreach (var Provider in Providers) { if (S[Provider.NodeNum]) { SecureProviderU += multihomedStub.U[Provider.NodeNum]; SecureProviders++; } TotalU += multihomedStub.U[Provider.NodeNum]; } // Console.WriteLine(iteration + " :: " + multihomedStub.destination + " " + SecureProviders + " " + TotalProviders + " " + SecureProviderU + " " + TotalU); finishedDests++; if ((finishedDests % 1000) == 0) { Console.WriteLine("Finished " + finishedDests + " at " + DateTime.Now + " iteration started at " + IterationStart); } } Console.WriteLine(DateTime.Now + " done iteration " + iteration + " it started at " + IterationStart); iteration++; } }
public AsInfo(AsNode node, DName identifier) { Contracts.AssertValue(node); Contracts.AssertValid(identifier); AsIdentifier = identifier; Node = node; }
public override LazyList <string> Visit(AsNode node, Precedence parentPrecedence) { Contracts.AssertValue(node); return(ApplyPrecedence( parentPrecedence, Precedence.As, node.Left.Accept(this, Precedence.As) .With(SpacedOper(TexlLexer.KeywordAs)) .With(node.Right.Token.ToString()))); }
private static int numStubChildren(List <UInt32> stubs, AsNode ASN) { int toreturn = 0; foreach (var child in ASN.GetNeighborsByType(RelationshipType.ProviderTo)) { if (stubs.Contains(child.NodeNum)) { toreturn++; } } return(toreturn); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (!Initialize(ref position, property, label)) { return; } int index = AsNode.GetGenericParameterIndex(property.name, fieldInfo.FieldType, Parameters); DrawBackground(position, index == -1 ? Color.red : Color.white); label = EditorGUI.BeginProperty(position, label, property); { position.y += BoxBackgroundHeight * 0.5f; position = EditorGUI.PrefixLabel(position, new GUIContent(property.displayName)); EditorGUI.indentLevel = 0; EditorGUI.BeginChangeCheck(); { var objectFieldRect = position; objectFieldRect.y += BoxBackgroundMargin; int result = EditorGUI.Popup ( objectFieldRect, GUIContent.none, index + 1, ParameterListContent.ToArray(), SpaceEditorStyles.ParametrizedField ); if (!Editor.ExecuteInRuntime()) { if (result > 0 && result <= Parameters.Count) { var parameter = Parameters[result - 1]; AsNode.SetRequiredParameter(property.name, parameter); } else { AsNode.ClearRequiredParamerer(property.name); } } } if (EditorGUI.EndChangeCheck()) { } } EditorGUI.EndProperty(); }
/// <summary> /// tells us if this ASN is connected to one of the big 5 or content providers. /// (excluding the point ASN) /// /// returns the list of such neighbors. /// </summary> /// <param name="ASN"></param> /// <param name="g"></param> /// <returns></returns> private static List <UInt32> hasCPT1Neighbor(AsNode ASN, UInt32 pointASN) { UInt32[] CPT1 = { 15169, 8075, 22822, 20940, 32934, 1239, 7018, 701, 174, 3356 }; List <UInt32> toreturn = new List <uint>(); foreach (var neighbor in ASN.GetAllNeighbors()) { if (neighbor.NodeNum != pointASN && CPT1.Contains(neighbor.NodeNum)) { toreturn.Add(neighbor.NodeNum); } } return(toreturn); }
public override Result Visit(AsNode node, Context context) { return(Default); }
public override void PostVisit(AsNode node) { }
public static void makeOutputScenarios(resultObject results) { /* Scenario 1: * - 1 file per large AS. File contains the AS and it's stub customers */ var stubs = results.g.getStubs(); UInt32[] highdegreeASes = { 701, 174, 3356, 7018, 1239, 209, 3549, 4323, 6939, 9002, 6461, 2828, 2914, 4589, 3856, 3561, 6762, 1299, 3320 }; UInt32[] CPs = { 15169, 8075, 22822, 32934, 20940 }; int numPrinted; foreach (UInt32 bigAS in highdegreeASes) { StreamWriter output = new StreamWriter(ATTdir + "AS" + bigAS + ".txt"); numPrinted = 1; List <UInt32> printedASes = new List <UInt32>(); output.WriteLine(bigAS); printedASes.Add(bigAS); AsNode curr = results.g.GetNode(bigAS); foreach (AsNode customer in curr.GetNeighborsByType(RelationshipType.ProviderTo)) { if (stubs.Contains(customer.NodeNum) && !printedASes.Contains(customer.NodeNum)) { printedASes.Add(customer.NodeNum); output.WriteLine(customer.NodeNum); numPrinted++; } } Console.WriteLine("printed " + numPrinted + " for AS " + bigAS); output.Close(); } /* Scenario 2: * - 1 file per CP. File contains the CP and it's peers. * */ foreach (UInt32 CP in CPs) { StreamWriter outputpeers = new StreamWriter(ATTdir + "CP-AS" + CP + "-peers.txt"); StreamWriter outputpeersandstubs = new StreamWriter(ATTdir + "CP-AS" + CP + "-peers-stubs.txt"); outputpeers.WriteLine(CP); outputpeersandstubs.WriteLine(CP); List <UInt32> printedASes1 = new List <UInt32>(); List <UInt32> printedASes2 = new List <UInt32>(); numPrinted = 1; AsNode curr = results.g.GetNode(CP); printedASes1.Add(CP); printedASes2.Add(CP); foreach (AsNode peer in curr.GetNeighborsByType(RelationshipType.PeerOf)) { if (!printedASes1.Contains(peer.NodeNum) && !printedASes2.Contains(peer.NodeNum)) { printedASes1.Add(peer.NodeNum); printedASes2.Add(peer.NodeNum); numPrinted++; outputpeers.WriteLine(peer.NodeNum); } foreach (AsNode peercustomer in peer.GetNeighborsByType(RelationshipType.ProviderTo)) { if (stubs.Contains(peercustomer.NodeNum) && !printedASes2.Contains(peercustomer.NodeNum)) { printedASes2.Add(peercustomer.NodeNum); outputpeersandstubs.WriteLine(peercustomer.NodeNum); } } } Console.WriteLine("printed " + printedASes1.Count + "peers for AS and " + printedASes2.Count + " peer/customers for " + CP); outputpeers.Close(); outputpeersandstubs.Close(); } }
public override LazyList <string> Visit(AsNode node, Context context) { Contracts.AssertValue(node); return(Basic(node, context)); }
public static void trafficThroughSecureProviders(resultObject results) { //get what the simulation state would look like. GlobalState GS = SimulatorLibrary.initGlobalState(results.g, results.earlyAdopters, results.weightedNodes, short.Parse(results.k)); /** First, get a list of multihomed stubs as destinations **/ var stubs = results.g.getStubs(); List <UInt32> multihomedStubs = new List <UInt32>(); foreach (UInt32 stubNum in stubs) { AsNode stub = results.g.GetNode(stubNum); //if this stub is multihomed, init a destination. add it to the list. if (stub.GetNeighborsByType(RelationshipType.CustomerOf).ToArray().Length > 1) { multihomedStubs.Add(stubNum); } } Console.WriteLine(multihomedStubs.Count + " stubs out of " + stubs.Count + " are multihomed."); StreamWriter output = new StreamWriter("trafficThroughSecureProvider.txt"); /** Second, go through each iteration... **/ int iteration = 0; foreach (bool[] S in results.state) { DateTime IterationStart = DateTime.Now; Int32 numDone = 0; foreach (UInt32 multihomedStubNum in multihomedStubs) { /** for this multhomed stub, see how much traffic * goes through secure providers **/ AsNode multihomedStub = results.g.GetNode(multihomedStubNum); Destination multihomedStubDest = new Destination(SimulatorLibrary.initMiniDestination(results.g, multihomedStubNum, false)); //computer the paths and utilities. multihomedStubDest.UpdatePaths(S); multihomedStubDest.ComputeU(GS.W); //get the providers. var Providers = multihomedStub.GetNeighborsByType(RelationshipType.CustomerOf); //count traffic through secure providers (and number of secure providers). Int64 TotalU = 0; Int64 SecureProviderU = 0; Int32 TotalProviders = Providers.Count(); Int32 SecureProviders = 0; foreach (var Provider in Providers) { if (S[Provider.NodeNum]) { SecureProviderU += multihomedStubDest.U[Provider.NodeNum]; SecureProviders++; } TotalU += multihomedStubDest.U[Provider.NodeNum]; } /*write out summary of how much traffic went through secure providers. */ output.WriteLine(iteration + " :: " + multihomedStubNum + " " + SecureProviders + " " + TotalProviders + " " + SecureProviderU + " " + TotalU); numDone++; if ((numDone % 100) == 0) { Console.WriteLine("Done " + numDone + " at " + DateTime.Now); } } //some benchmarking. Console.WriteLine(DateTime.Now + " done iteration " + iteration + " it started at " + IterationStart); iteration++; } output.Close(); }
public override Result Visit(AsNode node, Context context) { return(node.Left.Accept(this, context)); }
public abstract Result Visit(AsNode node, Context context);
/// <summary> /// return to us the list of stubs connected to ASN's neighbors who were /// off in state S /// </summary> /// <param name="ASN"></param> /// <param name="g"></param> /// <param name="S"></param> private static void getOffGrandChildrenStubs(AsNode ASN, List <UInt32> stubs, bool[] S) { }
public virtual bool PreVisit(AsNode node) { return(true); }
public static void getTieBreakSetSize(string[] commandPieces, resultObject Result) { if (commandPieces.Length < 2) { Console.WriteLine("usage: tiebreakset [AS+ASN | number to sample | b5t5 + number to sample ]"); return; } StreamWriter output = new StreamWriter(Console.OpenStandardOutput()); string bucketTableFile = "C:\\Users\\phillipa\\Desktop\\adoptTraffic\\Code\\AzureSecureSimulator\\MakeAllBucketTables\\bin\\Debug\\destinations2010\\"; if (commandPieces.Length > 2) { output.Close(); output = new StreamWriter(ResultsExplorer.defaultOutputDirectory + commandPieces[2]); Console.WriteLine("outputting results to: " + ResultsExplorer.defaultOutputDirectory + commandPieces[2]); } string arg = commandPieces[1]; List <AsNode> sampleASes = new List <AsNode>(); if (arg.IndexOf("AS") == 0) { //sampling on single AS } else if (arg.IndexOf("all") < 0) { if (arg.IndexOf("b5t5") == 0) { sampleASes.Add(Result.g.GetNode(22822)); sampleASes.Add(Result.g.GetNode(15169)); sampleASes.Add(Result.g.GetNode(8075)); sampleASes.Add(Result.g.GetNode(20940)); sampleASes.Add(Result.g.GetNode(32934)); sampleASes.Add(Result.g.GetNode(7018)); sampleASes.Add(Result.g.GetNode(701)); sampleASes.Add(Result.g.GetNode(174)); sampleASes.Add(Result.g.GetNode(1239)); sampleASes.Add(Result.g.GetNode(3356)); } arg = arg.Replace("b5t5", ""); int numSamples = 0; if (int.TryParse(arg, out numSamples)) { numSamples += sampleASes.Count; while (sampleASes.Count < numSamples) { AsNode rand = Result.g.GetRandomNode(); if (!sampleASes.Contains(rand)) { sampleASes.Add(rand); } } } } else if (arg.IndexOf("all") == 0) { sampleASes = Result.g.GetAllNodes().ToList(); } Console.WriteLine("initiated sample set of size : " + sampleASes.Count); List <double> stubBestSizes = new List <double>(); List <double> nonStubBestSizes = new List <double>(); List <double> BestSizes = new List <double>(); var stubs = Result.g.getStubs(); var nonstubs = Result.g.getNonStubs(); var allASNs = new List <UInt32>(); foreach (var node in Result.g.GetAllNodes()) { allASNs.Add(node.NodeNum); } foreach (var sample in sampleASes) { Destination curr = ObjectToText.destinationFromText(bucketTableFile + sample.NodeNum + ".csv"); //SimulatorLibrary.initMiniDestination(Result.g, sample.NodeNum, false); var bestSizes = getAverageBestSizes(curr, stubs, nonstubs, allASNs, output); var avgBest = bestSizes.all; var sBest = bestSizes.stubs; var nsBest = bestSizes.nonstubs; Console.WriteLine("{0} {1:0.00} {2:0.00}(stubs) {3:0.00}(nonstubs)", sample.NodeNum, avgBest, sBest, nsBest); stubBestSizes.Add(sBest); nonStubBestSizes.Add(nsBest); BestSizes.Add(avgBest); } Console.WriteLine("-------ALL ASes--------"); Console.WriteLine("AVG: {0:0.000} SD: {1:0.000} MIN: {2:0.000} MAX: {3:0.000}", getMean(BestSizes), getSD(BestSizes, getMean(BestSizes)), getMin(BestSizes), getMax(BestSizes)); Console.WriteLine("-------STUB ASes--------"); Console.WriteLine("AVG: {0:0.000} SD: {1:0.000} MIN: {2:0.000} MAX: {3:0.000}", getMean(stubBestSizes), getSD(stubBestSizes, getMean(stubBestSizes)), getMin(stubBestSizes), getMax(stubBestSizes)); Console.WriteLine("-------NONSTUB ASes--------"); Console.WriteLine("AVG: {0:0.000} SD: {1:0.000} MIN: {2:0.000} MAX: {3:0.000}", getMean(nonStubBestSizes), getSD(nonStubBestSizes, getMean(nonStubBestSizes)), getMin(nonStubBestSizes), getMax(nonStubBestSizes)); output.Close(); }
public abstract void PostVisit(AsNode node);