Beispiel #1
0
        /// <summary>
        /// remove degree 1 diamonds and diamonds not used for traffic.
        /// </summary>
        /// <param name="diamonds"></param>
        private static void removeBadDiamonds(ref Hashtable diamonds, UInt32 point, int diamondType, resultObject Result)
        {
            NetworkGraph g = Result.g;
            //Remove level 1 diamonds.
            var keysToRemove = new List <UInt32>();

            foreach (var key in diamonds.Keys)
            {
                if (((List <UInt32>)diamonds[key]).Count == 1)
                {
                    keysToRemove.Add((UInt32)key);
                }
            }

            foreach (var key in keysToRemove)
            {
                diamonds.Remove(key);
            }

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            int keysProcessed = 0;

            keysToRemove = new List <uint>();
            //for diamonds that arer peer nad provider make sure
            //the point doesn't have a better path
            // to the stub.

            foreach (var key in diamonds.Keys)
            {
                Destination k = ObjectToText.destinationFromText(bucketTableFile + key + ".csv");
                if (diamondType == _peerDiamonds)
                {
                    if (k.BestRelation[point] == Destination._CUSTOMERCOLUMN)
                    {
                        keysToRemove.Add((UInt32)key);
                    }
                }
                else if (diamondType == _providerDiamonds)
                {
                    if (k.BestRelation[point] == Destination._CUSTOMERCOLUMN)
                    {
                        keysToRemove.Add((UInt32)key);
                    }
                    else if (k.BestRelation[point] == Destination._PEERCOLUMN)
                    {
                        keysToRemove.Add((UInt32)key);
                    }
                }
                if (!keysToRemove.Contains((UInt32)key) && !checkFlipOrder(k, (List <UInt32>)diamonds[key], point, Result))
                {
                    keysToRemove.Add((UInt32)key);
                }

                keysProcessed++;
                if (keysProcessed % 500 == 0)
                {
                    Console.WriteLine("processed " + keysProcessed + " out of " + diamonds.Count + " in " + stopwatch.ElapsedMilliseconds + " ms" + DateTime.Now);
                }
            }

            stopwatch.Stop();
            Console.WriteLine("processed " + diamonds.Count + " in " + stopwatch.ElapsedMilliseconds + " ms");

            foreach (var key in keysToRemove)
            {
                diamonds.Remove(key);
            }
        }
Beispiel #2
0
        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();
        }