Ejemplo n.º 1
0
        private bool turnOnStubs(ref NetworkGraph g, ref bool[] S)
        {
            //clear S
            for (int i = 0; i < S.Length; i++)
                S[i] = false;
            List<UInt32> stubs = g.getStubs();
            foreach (int stub in stubs)
            {
                S[stub] = true;
            }

            return true;
        }
Ejemplo n.º 2
0
        private bool getproviders(ref NetworkGraph g, string command)
        {
            string resp;
            bool onlystubs = false;
            if (command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length < 2)
            {
                Console.WriteLine("Please enter a node to get the providers of");
                resp = Console.ReadLine();
            }
            else
            {
                resp = command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[1];
            }
            if (command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length > 2)
            {
                onlystubs = true;
                Console.WriteLine("you have indicated you are only interested in stub networks.");
            }
            UInt32 ASN;
            if (!UInt32.TryParse(resp, out ASN))
            {
                Console.WriteLine("invalid ASN.");
                return false;
            }
            AsNode n;
            List<UInt32> stubs = g.getStubs();
            if ((n = g.GetNode(ASN)) != null)
            {
                Console.WriteLine("Providers of AS: " + ASN + " are: (ie. AS is a customer of)");
                foreach (AsNode customer in n.GetNeighborsByType(RelationshipType.CustomerOf))
                {
                    if (!onlystubs || (stubs.Contains(customer.NodeNum)))
                    Console.Write(customer.NodeNum + " : ");
                }
                Console.WriteLine();

            }
            else
            {
                Console.WriteLine("AS: " + ASN + " was not found in the graph, are you sure it exists?");
                return false;
            }

            return true;
        }
Ejemplo n.º 3
0
        private bool printstubs(ref NetworkGraph g)
        {
            Console.WriteLine("printing stubs:");
            List<UInt32> stubs = g.getStubs();
            for (int i = 0; i < stubs.Count; i++)
                Console.WriteLine(stubs[i]);

            return true;
        }
Ejemplo n.º 4
0
        private List<bool[]> postProcessState(List<bool[]> unprocessedState, resultObject Params)
        {
            List<UInt32> big5 = new List<uint>();
            big5.Add(22822);
            big5.Add(8075);
            big5.Add(15169);
            big5.Add(20940);
            big5.Add(32934);

            List<bool[]> processedState = new List<bool[]>();
            string graphFile = graphDirectory + Params.graphFile;
            if (!File.Exists(graphFile))
                Console.WriteLine("I could not find the graph file: " + graphFile);

            NetworkGraph g = new NetworkGraph();
            InputFileReader ifr = new InputFileReader(graphFile, g);
            ifr.ProcessFile();

            List<UInt32> stubs = g.getStubs();

            /*** Process and add the initial state of the simulation ***/
            bool[] initialState = SimulatorLibrary.initGlobalState(g, Params.earlyAdopters).S;

            //walk over stubs and re-evaluate their state.
            foreach (UInt32 AS in stubs)
            {
                if (!big5.Contains(AS))
                {
                    AsNode node = g.GetNode(AS);
                    initialState[AS] = false;//default to false for this stub.
                    var parents = node.GetNeighborsByType(RelationshipType.CustomerOf).ToList<AsNode>();
                    // parents.AddRange(node.GetNeighborsByType(RelationshipType.PeerOf)); //don't turn on for peers
                    foreach (AsNode parent in parents)
                    {
                        if (initialState[parent.NodeNum])
                        {//parent is true let it be true in the augmented state.
                            initialState[AS] = true;
                            break;
                        }

                    }
                }

            }
            foreach (var AS in Params.earlyAdopters)
                initialState[AS] = true;//make sure early adopters are "on"

            processedState.Add(initialState);

            for (int i = 0; i < unprocessedState.Count; i++)
            {

                bool[] currS = unprocessedState[i];
                //walk over stubs and re-evaluate their state.
                foreach (UInt32 AS in stubs)
                {
                    if (!big5.Contains(AS))
                    {
                        AsNode node = g.GetNode(AS);
                        currS[AS] = false;//default to false for this stub.
                        var parents = node.GetNeighborsByType(RelationshipType.CustomerOf).ToList<AsNode>();
                        // parents.AddRange(node.GetNeighborsByType(RelationshipType.PeerOf)); //don't turn on for peers
                        foreach (AsNode parent in parents)
                        {
                            if (currS[parent.NodeNum])
                            {//parent is true let it be true in the augmented state.
                                currS[AS] = true;
                                break;
                            }

                        }
                    }
                }

                foreach (var AS in Params.earlyAdopters)
                    currS[AS] = true;//make sure early adopters are "on"

                processedState.Add(currS);
            }

            return processedState;
        }