Пример #1
0
        public static GlobalState GlobalStateFromBlob(string containerName, string blobName)
        {
            GlobalState globalState = new GlobalState();
            const int S = 0;
            const int W = 1;
            const int nonStubs = 2;
            int currentlyReading = -1;
            StreamReader input = new StreamReader(BlobLibrary.getBlobReadStream(containerName, blobName));
            while (!input.EndOfStream)
            {
                string line = input.ReadLine().ToLower();
                string[] pieces = line.Split(space, StringSplitOptions.RemoveEmptyEntries);
                if (line[0] == '#')
                {

                     if (line.IndexOf("nonstubs") >= 0)
                    {
                        globalState.nonStubs = new List<UInt32>();
                        currentlyReading = nonStubs;
                    }
                    else if (line.IndexOf("s") >= 0)
                    {
                        Int32 len = Int32.Parse(pieces[1]);
                        globalState.S = new bool[len];
                        currentlyReading = S;
                    }
                       else if (line.IndexOf("w") >= 0)
                    {
                        Int32 len = Int32.Parse(pieces[1]);
                        globalState.W = new UInt16[len];
                        currentlyReading = W;
                    }
                }
                else
                {
                    switch (currentlyReading)
                    {
                        case S:
                            for (int i = 0; i < pieces.Length; i++)
                                globalState.S[i] = bool.Parse(pieces[i]);
                            break;
                        case W:
                            for (int i = 0; i < pieces.Length; i++)
                                globalState.W[i] = UInt16.Parse(pieces[i]);
                            break;
                        case nonStubs:
                            for (int i = 0; i < pieces.Length; i++)
                                globalState.nonStubs.Add(UInt32.Parse(pieces[i]));
                            break;
                    }
                }

            }

            input.Close();

            return globalState;
        }
Пример #2
0
        public void testSPInterface()
        {
            SimulatorLibrary.setHash(true);
               SimulatorLibrary.setUtilityComputation(UtilityComputationType.outgoing);
            Console.WriteLine("Welcome to the short paths testing interface: ");
            bool exitNow = false;

            while (!exitNow)
            {

                Console.Write(">>");
                string command = Console.ReadLine().ToLower();
                string[] pieces = command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                if (command.IndexOf("input") == 0)
                {
                    g = input(pieces);
                }
                else if (command.IndexOf("getpath") == 0)
                {
                    getpath(pieces);
                }
                else if (command.IndexOf("setstate") == 0)
                    S = setstate(pieces);
                else if (command.IndexOf("init") == 0)
                {
                    List<UInt32> ea = new List<uint>();
                    ea.Add(1239);
                    gs = SimulatorLibrary.initGlobalState(g, ea);

                }
                else if (command.IndexOf("iterate") == 0)
                {
                    List<MiniDestination> miniDs = new List<MiniDestination>();
                    foreach (var AS in g.GetAllNodes())
                    {
                        miniDs.Add(SimulatorLibrary.initMiniDestinationSP(g,AS.NodeNum,false));
                        Console.WriteLine("initialized AS " + AS.NodeNum);
                    }

                    List<Message> results= new List<Message>();
                    foreach(var mD in miniDs)
                    {
                        results.Add(SimulatorLibrary.ComputeOnDestination(mD,gs));
                        Console.WriteLine("computed on: " + mD.destination);
                    }
                    Console.WriteLine("updating global state.");
                    Int64[] Before = new Int64[Constants._numASNs];
                   Int64[] After = new Int64[Constants._numASNs];

                    SimulatorLibrary.updateGlobalState(ref gs, results,(float)0,ref Before,ref After);
                    for (int i = 0; i < gs.S.Length; i++)
                        if (gs.S[i])
                            Console.WriteLine("AS " + i + " is on.");
                    }
            }
        }
Пример #3
0
        public static void GlobalStateToBlob(GlobalState globalState, string containerName, string blobName)
        {
            StreamWriter output = new StreamWriter(BlobLibrary.getBlobWriteStream(containerName, blobName));
            output.WriteLine("#S " + globalState.S.Length);
            for (int i = 0; i < globalState.S.Length; i++)
                output.Write(globalState.S[i] + " ");
            output.Write("\n");

            output.WriteLine("#W " + globalState.W.Length);
            for (int i = 0; i < globalState.W.Length; i++)
                output.Write(globalState.W[i] + " ");
            output.Write("\n");
            output.WriteLine("#Nonstubs " + globalState.nonStubs.Count);
            for (int i = 0; i < globalState.nonStubs.Count; i++)
                output.Write(globalState.nonStubs[i] + " ");
            output.Write("\n");
            output.Close();
        }
Пример #4
0
        private bool flipallU(ref List<Destination> ds, ref NetworkGraph g, ref GlobalState globalState, string command)
        {
            Console.WriteLine("Flipping state:");

            string[] cpieces = command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (cpieces.Length < 1)
            {
                Console.WriteLine("usage: flipallu <quiet?>");
                return false;
            }

            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            List<UInt32> toflip = new List<UInt32>();
            bool quiet = false;
            if (command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length > 1)
            {
                quiet = true;
                Console.WriteLine("you have selected quiet mode");
            }
            List<UInt32> nonstubs = g.getNonStubs();
            Int64[] deltaU = new Int64[Constants._numASNs];
            for (int i = 0; i < deltaU.Length; i++)
                deltaU[i] = 0;

            foreach (Destination d in ds)
            {
                foreach (UInt32 ASN in nonstubs)
                {
                    if (d.Best[ASN] != null)//make sure this AS has a route to our destination
                    {
                        Worker w = new Worker();
                        int notASN = w.ComputeUtility(d.BucketTable, d.Best, d.ChosenParent, d.SecP, globalState.S, ASN, d.L[ASN], d.BestRelation[ASN], globalState.W);

                        deltaU[ASN] += (notASN - d.U[ASN]);

                    }
                }
            }
            int flipped = 0;
            for (int ASN = 0; ASN < deltaU.Length;ASN++ )
            {
                if (deltaU[ASN] > 0)//positive change in utility for this ASN
                {
                    flipped++;
                    if (globalState.S[ASN])
                        Console.WriteLine("AS: " + ASN + " is rolling back!!!");
                    globalState.S[ASN] = !globalState.S[ASN];
                    if (!quiet)
                    {
                        Console.WriteLine("AS: " + ASN + " had change in utility of " + deltaU[ASN]);
                    }
                }

            }
            stopwatch.Stop();
            Console.WriteLine("flip u took " + stopwatch.ElapsedMilliseconds + " ms");
            Console.WriteLine("it flipped " + flipped + " ASes");
            return true;
        }
Пример #5
0
        private bool flipU(ref List<Destination> ds, ref NetworkGraph g, ref GlobalState globalState,string command)
        {
            Console.WriteLine("Flipping state:");

            string[] cpieces = command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (cpieces.Length < 2)
            {
                Console.WriteLine("usage: flipu <d> <quiet?>");
                return false;
            }

            Destination d = new Destination();
            UInt32 destNum;
            if (!UInt32.TryParse(cpieces[1], out destNum))
            {
                Console.WriteLine("invalid destination number");
                return false;
            }
            foreach (Destination curr in ds)
            {
                if (curr.destination == destNum)
                    d = curr;
            }
            if (d.BucketTable == null)
            {
                Console.WriteLine("null bucket table!");
                return false;
            }

            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            List<UInt32> toflip = new List<UInt32>();
            bool quiet = false;
            if (command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length > 2)
            {
                quiet = true;
                Console.WriteLine("you have selected quiet mode");
            }

            List<UInt32> nonstubs = g.getNonStubs();
            foreach (UInt32 ASN in nonstubs)
            {
                if (d.Best[ASN] != null)//make sure this AS has a route to our destination
                {
                    Worker w = new Worker();
                    int notASN = w.ComputeUtility(d.BucketTable, d.Best, d.ChosenParent, d.SecP, globalState.S, ASN, d.L[ASN], d.BestRelation[ASN], globalState.W);
                    if (d.U[ASN] < notASN)
                    {
                        if (!quiet)
                            Console.WriteLine("AS: " + ASN + " from " + globalState.S[ASN] + " to " + !globalState.S[ASN]);
                        toflip.Add(ASN);//don't flip on the fly it messes up everyones calculations, do it at the end.
                    }
                }
            }

            foreach (int ASN in toflip)
            {
                if (globalState.S[ASN])
                    Console.WriteLine("AS: " + ASN + " is rolling back!!!");
                globalState.S[ASN] = !globalState.S[ASN];

            }
            stopwatch.Stop();
            Console.WriteLine("flip u took " + stopwatch.ElapsedMilliseconds + " ms");
            Console.WriteLine("it flipped " + toflip.Count + " ASes");
            return true;
        }
Пример #6
0
        private bool compareU(ref List<Destination> ds, ref GlobalState globalState,ref NetworkGraph g,string command)
        {
            string[] cpieces = command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (cpieces.Length < 2)
            {
                Console.WriteLine("usage: compareu <d> <onlybenefit?>");
                return false;
            }
            /** first off try to parse out a specific destination (or all) **/

            UInt32 destNum;
            if (!UInt32.TryParse(cpieces[1], out destNum) && !cpieces[1].Equals("all"))
            {
                Console.WriteLine("invalid destination number");
                return false;
            }
            List<Destination> destinationsToCompare = new List<Destination>();
            if (cpieces[1].Equals("all"))
            {
                //want to run on all destinations.
                destinationsToCompare = ds;
            }
            else
            {
                foreach (Destination curr in ds)
                {
                    if (curr.destination == destNum)
                        destinationsToCompare.Add(curr);
                }
            }
            /** next see if we have been asked only for nodes that benefit **/
            bool onlybenefit = false;
            if (command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length > 2)
            {
                Console.WriteLine("you've chosen to only display ASes that benefit");
                onlybenefit = true;
            }

            List<UInt32> nonstubs = g.getNonStubs();
            Worker w = new Worker();
            foreach (Destination d in destinationsToCompare)
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                Console.WriteLine("Destination : " + d.destination);
                Console.WriteLine("ASN :: U(before) : U(flipped)");
                runCompareU(nonstubs, d, ref w, onlybenefit,ref globalState);
                stopwatch.Stop();
                Console.WriteLine("compare u took " + stopwatch.ElapsedMilliseconds + " ms");
            }
            return true;
        }
Пример #7
0
        private bool computeNotN(ref List<Destination> ds, ref GlobalState globalState, ref Worker w, string command)
        {
            string[] cpieces = command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (cpieces.Length < 3)
            {
                Console.WriteLine("error: usage getpath <as#> <dstnum>");
                return false;
            }

            int dstNum;
            UInt32 ASN;
            if (!UInt32.TryParse(cpieces[1], out ASN) || !int.TryParse(cpieces[2],out dstNum))
            {
                Console.WriteLine("invalid ASN or destination.");
                return false;
            }

            foreach (Destination d in ds)
            {
                if (d.destination == dstNum)
                {
                    Stopwatch stopwatch = new Stopwatch();
                    stopwatch.Reset();
                    stopwatch.Start();
                    int unotn = w.ComputeUtility(d.BucketTable, d.Best, d.ChosenParent, d.SecP, globalState.S, ASN, d.L[ASN], d.BestRelation[ASN], globalState.W);
                    stopwatch.Stop();

                    Console.WriteLine("Utility for " + ASN + " if they flip is: " + unotn + " computing this took " + stopwatch.ElapsedMilliseconds);
                    return true;
                }
            }
            Console.WriteLine("could not find destination.");
            return false;
        }
Пример #8
0
        private void runCompareU(List<UInt32> nonstubs,Destination d,ref Worker w,bool onlybenefit,ref GlobalState globalState)
        {
            if (d.BucketTable == null)
            {
                Console.WriteLine("null bucket table!");
                return;
            }
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Reset();
            stopwatch.Start();
            d.UpdatePaths(globalState.S);
            d.ComputeU(globalState.W);//just in case.
            stopwatch.Stop();

            foreach (UInt32 ASN in nonstubs)
            {
                if (d.Best[ASN] != null)//nonstub has a path to d
                {
                    int notASN = w.ComputeUtility(d.BucketTable, d.Best, d.ChosenParent, d.SecP, globalState.S, ASN, d.L[ASN], d.BestRelation[ASN], globalState.W);
                    if (!onlybenefit || d.U[ASN] < notASN)
                        Console.WriteLine(ASN + " :: " + d.U[ASN] + " : " + notASN);
                }
            }
            Console.WriteLine("update paths and compute u took: " + stopwatch.ElapsedMilliseconds + " ms");
        }
Пример #9
0
        public void CLI(bool script)
        {
            bool debug = false;
            bool decoy_sim = false;

            string resp;
            List<Destination> d = new List<Destination>();
            NetworkGraph g = new NetworkGraph();
            Worker w = new Worker();
            bool[] S = new bool[Constants._numASNs];
            for (int i = 0; i < S.Length; i++)
                S[i] = false;
            GlobalState globalState = new GlobalState();
            globalState.S = S;
            StreamReader input = new StreamReader( Console.OpenStandardInput());
            if (script)
            {
                Console.WriteLine("You have selected to run a script, please enter the file name:");
                string scriptfile = Console.ReadLine();
                if (!File.Exists(scriptfile))
                    Console.WriteLine("script file: " + scriptfile + " did not exist, entering interactive mode");
                else
                    input = new StreamReader(scriptfile);
            }
            globalState.W = new UInt16[Constants._numASNs];
            for (int i = 0; i < globalState.W.Length; i++)
                globalState.W[i] = 1;

            Console.WriteLine("Welcome to the testing interface: (type help for help) Haseeb Mac");
            bool exitNow = false;

            //Automatcally load Cyclops_caida.txt
            if (decoy_sim)
            {
                String load = "inputfile decoy/Cyclops_poison.txt";
                initGraph(ref g, load);
                globalState.nonStubs = g.getNonStubs();
                Console.WriteLine("Cyclops_poison.txt Loaded!");
            } else {
                String load = "inputfile Cyclops_caida_new.txt";
                initGraph(ref g, load);
                globalState.nonStubs = g.getNonStubs();
                Console.WriteLine("Cyclops_caida_new.txt Loaded!");
            }

            //DEBUG
            if (debug) {
                String debugC = "analysepathfile test.txt";
                analysePathfile (ref g, debugC);
                exitNow = true;
            } else if (decoy_sim) {
                string dst;

                using (StreamReader reader = new StreamReader("decoy/helper.txt")) {
                    dst = reader.ReadLine();
                }
                String decoyC = "all_path_info " + dst;
                all_path_info(ref d, ref g, decoyC);
                exitNow = true;
            }

            while(!exitNow)
            {
                if (input.EndOfStream)
                {
                    input.Close();
                    input = new StreamReader(Console.OpenStandardInput());
                    Console.WriteLine("script has ended, now in interactive mode");
                }
                Console.Write(">>");
                string command = input.ReadLine().ToLower();

                if (command.IndexOf ("input") == 0) {
                    initGraph (ref g, command);
                    globalState.nonStubs = g.getNonStubs ();
                } else if (command.IndexOf ("destination") == 0) {

                    if (command.IndexOf ("all") < 0) {
                        Destination newD = new Destination ();
                        if (initDestination (ref g, ref newD, command)) {
                            d.Add (newD);
                            Console.WriteLine ("initialized and added " + newD.destination);
                        }
                    } else {
                        IEnumerable<AsNode> allASes = g.GetAllNodes ();
                        foreach (AsNode AS in allASes) {
                            Destination newD = new Destination ();
                            if (initDestination (ref g, ref newD, "destination " + AS.NodeNum)) {
                                d.Add (newD);
                                Console.WriteLine ("initialized and added " + newD.destination);
                            }
                        }
                    }

                } else if (command.IndexOf ("resultsexplorer") == 0) {
                    ResultsExplorer res = new ResultsExplorer ();
                    res.ResultsInterface ();
                } else if (command.IndexOf ("setstate") == 0)
                    initS (ref  globalState.S, command);
                else if (command.IndexOf ("addedges") == 0)
                    addEdges (command, ref g);
                else if (command.IndexOf ("getlink") == 0)
                    getLink (command, ref g);
                else if (command.IndexOf ("flipallu") == 0)
                    flipallU (ref d, ref g, ref globalState, command);
                else if (command.IndexOf ("printstate") == 0)
                    printState (ref  globalState.S, command);
                else if (command.IndexOf ("printsecp") == 0)
                    printSecP (ref d, command);
                else if (command.IndexOf ("getl") == 0)
                    getL (ref d, command);
                else if (command.IndexOf ("getw") == 0)
                    getW (ref globalState.W, command);
                else if (command.IndexOf ("printw") == 0)
                    printWeight (ref globalState.W, command);
                else if (command.IndexOf ("setw") == 0)
                    setW (ref globalState.W, command);
                else if (command.IndexOf ("getbestnew") == 0)
                    getBestNew (ref d, command);
                else if (command.IndexOf ("getbest") == 0)
                    getBest (ref d, command);
                else if (command.IndexOf ("all_path_info") == 0)
                    all_path_info (ref d, ref g, command);
                else if (command.IndexOf ("getpath") == 0)
                    getPath (ref d, ref g, command);
                else if (command.IndexOf ("analysepathfile") == 0)
                    analysePathfile (ref g, command);
                else if (command.IndexOf ("analysepath") == 0)
                    analysePath (ref g, command);
                else if (command.IndexOf ("serialise") == 0)
                    serialisePathArrays (ref g, command);
                else if (command.IndexOf ("getallpathsoflength") == 0)
                    getAllPathsoflength (ref d, ref g, command);
                else if (command.IndexOf ("getallpathsto") == 0)
                    getAllPathsTo (ref d, ref g, command);
                else if (command.IndexOf ("getallpaths") == 0)
                    getAllPaths (ref d, ref g, command);
                else if (command.IndexOf("getsecp") == 0)
                    getSecP(ref d, command);
                else if (command.IndexOf("getutility") == 0)
                    getUtility(ref d, command);
                else if (command.IndexOf("onlynonstubs") == 0)
                    SimulatorLibrary.setOnlyStubs(true);
                else if (command.IndexOf("notonlynonstubs") == 0)
                    SimulatorLibrary.setOnlyStubs(false);
                else if (command.IndexOf("iterateall") == 0)
                    iterateAll(ref d, ref g, ref globalState, command);
                else if (command.IndexOf("iterate") == 0)
                    iterate(ref d, ref  globalState, command);
                else if (command.IndexOf("not") == 0)
                    computeNotN(ref d, ref globalState, ref w, command);
                else if (command.IndexOf("wgetsecp") == 0)
                    getWorkerSecP(ref w, command);
                else if (command.IndexOf("checkpath") == 0)
                    checkPath(command);
                else if (command.IndexOf("initglobalstate") == 0)
                    initGlobalState(command, ref g, ref globalState);
                else if (command.IndexOf("wgetpath") == 0)
                    getWorkerPath(ref w, command);
                else if (command.IndexOf("wgetparent") == 0)
                    getWorkerParent(ref w, command);
                else if (command.IndexOf("printbuckettable") == 0)
                    printBucketTable(ref d, command);
                else if (command.IndexOf("compareu") == 0)
                    compareU(ref d, ref  globalState, ref g, command);
                else if (command.IndexOf("flipu") == 0)
                    flipU(ref d, ref g, ref globalState, command);
                else if (command.IndexOf("getnonstubs") == 0)
                    printnonstubs(ref g);
                else if (command.IndexOf("getstubs") == 0)
                    printstubs(ref g);
                else if (command.IndexOf("turnonstubs") == 0)
                    turnOnStubs(ref g, ref  globalState.S);
                else if (command.IndexOf("getcustomers") == 0)
                    getcustomers(ref g, command);
                else if (command.IndexOf("getpeers") == 0)
                    getpeers(ref g, command);
                else if (command.IndexOf("getproviders") == 0)
                    getproviders(ref g, command);
                else if (command.IndexOf("gets") == 0) //must be tested for after getsecp
                    getS(ref  globalState.S, command);
                else if (command.IndexOf("sets") == 0) //this must be tested for *after* the test for setstate
                    setS(ref  globalState.S, command);
                else if (command.IndexOf("computehash") == 0)
                    computeHash(command);
                else if (command.IndexOf("setutilitycomputation") == 0)
                    setUtilityComputation(command);
                else if (command.IndexOf("numberon") == 0)
                    numberOn(ref  globalState.S);
                else if (command.IndexOf("getaveragebest") == 0)
                    getAverageBest(command, ref d);
                else if (command.IndexOf("nodeswithnopath") == 0)
                    nodesWithNoPath(command, ref d, ref g);
                else if (command.IndexOf("traversedod") == 0)
                    DoDAnaly.traverseDoD(g);
                else if (command.IndexOf("clear") == 0)
                {
                    Console.WriteLine("clearing state of graph, destination, S and worker.");

                    g = new NetworkGraph();
                    for (int i = 0; i < S.Length; i++)
                        S[i] = false;
                    d = new List<Destination>();
                    w = new Worker();
                }
                else if (command.IndexOf("help") == 0)
                    help();
                else if (command.IndexOf("list") == 0)
                {
                    Console.WriteLine("printing current directory contents:");
                    string[] dirContents = Directory.GetFiles(".");
                    foreach (string s in dirContents)
                        Console.WriteLine(s);
                }
                else if (command.IndexOf("exit") == 0)
                    exitNow = true;

                Console.Write(">>");
            }

            input.Close();
        }
Пример #10
0
        private bool iterateAll(ref List<Destination> d, ref NetworkGraph g, ref GlobalState globalState, string command)
        {
            string[] parameters = command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            float percentage = 0;
            if (parameters.Length == 1)
                Console.WriteLine("no utility percentage specified, using basic condition that U after must be more than U before");
            else if (!float.TryParse(parameters[1], out percentage))
            {
                percentage = 0;
                Console.WriteLine("could not parse the utility percentage. using default condition Uafter > Ubefore to flip");
            }
            bool useMiniDWeight = false;

            if (parameters.Length > 2 && parameters[2].IndexOf("t")>=0)
            {
                useMiniDWeight = true;
                Console.WriteLine("using mini d weight.");
            }

            List<Message> results = new List<Message>();
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Reset();
            stopwatch.Start();
            foreach (Destination dest in d)
            {
                //yes this is pretty dumb/inefficient it is just for testing purposes.
                MiniDestination mD = SimulatorLibrary.initMiniDestination(g, dest.destination, false);

                results.Add(SimulatorLibrary.ComputeOnDestination(mD, globalState));
            }
            Int64[] Before = new Int64[Constants._numASNs];
            Int64[] After = new Int64[Constants._numASNs];
               SimulatorLibrary.updateGlobalState(ref globalState, results, percentage,ref Before,ref After);
               stopwatch.Stop();
               Console.WriteLine("iteration took: " + stopwatch.ElapsedMilliseconds);

            return true;
        }
Пример #11
0
        private bool iterate(ref List<Destination> ds, ref GlobalState globalState, string command)
        {
            string resp="0";

            if (command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length >= 2)
                resp = command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[1];

            UInt32 destNum=0;
            if (!UInt32.TryParse(resp, out destNum))
            {
                Console.WriteLine("Error invalid destination number.");
                return false;
            }

            foreach (Destination d in ds)
            {
                if (d.destination == destNum)
                {
                    Console.WriteLine("running utility and updatepaths for destination: " + d.destination + " minrow: " + 0);
                    d.UpdatePaths(globalState.S);
                    d.ComputeU(globalState.W);

                    return true;
                }
            }
            Console.WriteLine("could not find destination.");
            return false;
        }
Пример #12
0
        private bool initGlobalState(string command, ref NetworkGraph g, ref GlobalState globalState)
        {
            if (command.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length < 2)
            {
                Console.WriteLine("usage: initglobalstate :early adopters:top x:top x%");
                Console.WriteLine("e.g., initglobalstate :15169 8075:8075 22822:40 will set security true for 15169 and 8075 and assign 40 % weight total to 8075 and 22822 with remaining 60% divided across other ASs");
                return false;
            }

            string [] parameters= command.Split(":".ToCharArray(),StringSplitOptions.RemoveEmptyEntries);

            if (parameters.Length != 4)
            {
                Console.WriteLine("usage: initglobalstate :early adopters:top x:top x%");
                Console.WriteLine("e.g., initglobalstate :15169 8075:8075 22822:40 will set security true for 15169 and 8075 and assign 40 % weight total to 8075 and 22822 with remaining 60% divided across other ASs");
                return false;
            }

            List<UInt32> earlyAdopters = new List<UInt32>();
            string[] earlyAdopterStrings = parameters[1].Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            foreach (string eAS in earlyAdopterStrings)
            {
                UInt32 currAdopter;
                if (UInt32.TryParse(eAS, out currAdopter))
                {
                    if (g.GetNode(currAdopter) != null)
                        earlyAdopters.Add(currAdopter);
                    else
                        Console.WriteLine(currAdopter + " was not in the graph.");
                }
                else
                    Console.WriteLine("could not parse AS: " + eAS);
            }
            List<UInt32> topX = new List<UInt32>();
            string[] topXStrings = parameters[2].Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            foreach (string tXS in topXStrings)
            {
                UInt32 currTopX;
                if (UInt32.TryParse(tXS, out currTopX))
                {
                    if (g.GetNode(currTopX) != null)
                        topX.Add(currTopX);
                    else
                        Console.WriteLine(currTopX + " was not in the graph.");
                }
                else
                    Console.WriteLine("could not parse AS: " + tXS);
            }

            short topXPercent;
            if (!short.TryParse(parameters[3], out topXPercent))
            {
                Console.WriteLine("could not parse your top X percent value!");
                return false;
            }

            Console.WriteLine("dividing " + topXPercent + " across ");
            foreach (UInt32 topXAS in topX)
                Console.Write(topXAS + ", ");
            Console.WriteLine();
            Console.WriteLine("turning on stubs and ");
            foreach (UInt32 adopter in earlyAdopters)
                Console.Write(adopter + ", ");
            Console.WriteLine();

            globalState = SimulatorLibrary.initGlobalState(g, earlyAdopters, topX, topXPercent);
            return true;
        }