Example #1
0
        /// <summary>
        /// wysyla chmurze xml z linkami
        /// </summary>
        /// <param name="managerCloud"></param>
        public static void ConfigureLinkConnections(Manager managerCloud)
        {
            CLI.RequestXML();
            string name;

            do
            {
                name = Console.ReadLine();

                if (name == "esc")
                {
                    break;
                }
                XML.SetName(name);
            } while (XML.Test() != true);

            if (name != "esc")

            {
                XMLParser xml = new XMLParser(name);
                Program.links = xml.GetLinks();
                managerCloud.Send(XML.StringCableLinks(name));
                CLI.PrintConfigFilesSent();
            }
        }
Example #2
0
        /// <summary>
        /// Inicjalizacja działania sieci
        /// </summary>
        public void Init()
        {
            Dictionary <int, string> nodeFiles = parser.ReadXml("config.xml");

            foreach (KeyValuePair <int, string> ipAddress in networkNodeIPAddresses)
            {
                SendData(ipAddress.Value, nodeFiles[ipAddress.Key]);
                CLI.PrintSentXML(nodeFiles[ipAddress.Key], ipAddress.Key);
                Listen();
            }

            SendData("127.0.0.1", nodeFiles[0]);
            Listen();
            CLI.PrintConfigFilesSent();
        }
Example #3
0
        /// <summary>
        /// konfiguracja sieci w mpls
        /// </summary>
        public static void Configure(int nodeAmount, List <Manager> manager, int clientAmount, List <Manager> managerClient, Manager managerCloud)
        {
            CLI.RequestXML();
            string name;

            do
            {
                name = Console.ReadLine();

                if (name == "esc")
                {
                    break;
                }
                XML.SetName(name);
            } while (XML.Test() != true);
            if (name != "esc")
            {
                for (int i = 1; i <= nodeAmount; i++)
                {
                    try
                    {
                        manager[i - 1].Send(XML.StringNode(i));
                    }
                    catch (Exception ex)
                    {
                    }
                }

                for (int i = 1; i <= clientAmount; i++)
                {
                    try
                    {
                        managerClient[i - 1].Send(XML.StringClients());
                    }
                    catch (Exception ex)
                    {
                    }
                }
                managerCloud.Send(XML.StringCableLinks(name));
                CLI.PrintConfigFilesSent();
            }
        }
Example #4
0
        public static void ConfigureSubnetworks()
        {
            CLI.RequestXML();
            string name;

            do
            {
                name = Console.ReadLine();

                if (name == "esc")
                {
                    break;
                }
                XML.SetName(name);
            } while (XML.Test() != true);
            if (name != "esc")
            {
                Program.managerCloud.Send("clean_dictionary");
                XMLeonSubnetwork file = new XMLeonSubnetwork(name);


                CLI.PrintConfigFilesSent();

                lock (Program.subnetworksList)
                {
                    Program.subnetworksList = file.GetSubnetworks();
                    foreach (Subnetwork sub in Program.subnetworksList)
                    {
                        lock (Program.subnetworkManager)
                        {
                            try
                            {
                                Program.subnetworkManager.Find(x => x.number == sub.id).Send(sub.myContent);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine("Nie udała się konfiguracja podsieci, ex:" + ex.ToString());
                            }
                        }
                    }
                }
                string client;
                client = file.GetClientFile();

                List <int> portOut = XMLeon.GetClientPortOut(client);
                for (int i = 0; i < Program.amountOfclients; i++)
                {
                    try
                    {
                        Program.managerClient[i].Send("port_out:" + portOut[i]);
                        Console.WriteLine("Wysyłam info o porcie: " + portOut[i]);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Błąd wysyłania informacji o porcie");
                    }
                }
                string    linksFile = file.GetLinkFile();
                XMLParser xml       = new XMLParser(linksFile);
                Program.links = xml.GetLinks();
                lock (Program.managerCloud)
                {
                    Program.managerCloud.Send(XML.StringCableLinks(linksFile));
                    //Console.WriteLine("aaaaaaaaaaaaaaaaaaaaaaaaaaa");
                }
            }
        }
        /// <summary>
        /// odpowiada za polaczenie sie z tymi wszystkimi wezlami na samy dole
        /// gdy juz wiemy ze nasz manger jest tym najnizszym managerem
        ///
        /// </summary>
        /// <param name="message"></param>
        static void ConnectSubnetwork(string message)
        {
            // Console.Write(DateTime.Now.ToString("HH:mm:ss") + " : ");
            Console.WriteLine(" Zadanie konfiguracji podsieci");
            XmlDocument xmlDoc = new XmlDocument();

            try
            {
                xmlDoc.LoadXml(message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Niepoprawny format wiadomości, ex:" + ex.ToString());
            }
            XMLeonSubnetwork eonXml   = new XMLeonSubnetwork(xmlDoc);
            string           linkFile = eonXml.GetLinkFile();
            XMLParser        xml      = new XMLParser(linkFile);

            Program.links = xml.GetLinks();
            lock (Program.managerCloud)
            {
                Program.managerCloud.Send(XML.StringCableLinks(linkFile));
            }
            CLI.PrintConfigFilesSent();

            //laczenie sie z wezlami w podsieci
            lock (Program.managerNodes)
            {
                //i jest do indeksacji Program.managerNodes
                int i = 0;
                foreach (Node node in Program.nodes)
                {
                    Program.managerNodes.Add(new Manager(node.number));
                    Program.managerNodes[i].CreateSocket("127.0.4." + node.number, 11001);
                    while (true)
                    {
                        try
                        {
                            Program.managerNodes[i].Connect("127.0.3." + node.number, 11001);
                            break;
                        }
                        catch
                        {
                        }
                    }

                    //uruchuchomienie thread pingow do wezlow
                    try
                    {
                        Thread threadPing = new Thread(new ThreadStart(Program.managerNodes[i].PingThread));
                        threadPing.Start();
                    }
                    catch
                    {
                        Console.WriteLine("Nie udało się włączyć pinga");
                    }

                    i++;
                }
            }
        }