Example #1
0
        static void Main(String[] args)
        {
            try {
                args = Environment.GetCommandLineArgs();

                new Thread(() => {
                    Thread.Sleep(1000);
                    try {
                        String config = String.Concat(File.ReadAllLines(args[1]));
                        ConfigLoader.loadConfig(config, args[2]);

                        //String config = String.Concat(File.ReadAllLines("./../../../../sharedResources/tsst_config.xml"));
                        //ConfigLoader.loadConfig(config, "1");


                        //String config = String.Concat(File.ReadAllLines("./../../../../sharedResources/tsst_config.xml"));
                        //ConfigLoader.loadConfig(config);
                        //String config = String.Concat(File.ReadAllLines(args[1]));
                        //ConfigLoader.LoadConfig(config, args[2]);
                        ncc    = new NCC();
                        server = new Server(ncc);

                        if (ConfigLoader.ccID == 2)
                        {
                            interCCServer = new InterCcCommunicationServer(ncc);
                        }
                        else if (ConfigLoader.ccID == 1)
                        {
                            peerConnection = new PeerConnection(new TcpClient("localhost", 12500), true, ncc);
                        }
                        else
                        {
                            childConnection = new ChildConnection(new TcpClient("localhost", 12500), ncc);
                        }
                        GUIWindow.UpdateChannelTable();
                    }
                    catch (Exception e) {
                        GUIWindow.PrintLog(e.StackTrace);
                    }
                }).Start();

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new GUIWindow());
            }
            catch (Exception ex) {
                GUIWindow.PrintLog(ex.StackTrace);
            }
        }
Example #2
0
        public bool FastReroute(Call call, int connectionID)
        {
            GUIWindow.PrintLog("RC: Received RouteTableQuery(" + connectionID + ") from CC");

            Path        oldPath = call.GetPath();
            List <Path> paths   = null;

            try {
                paths = Algorithms.AllPaths(oldPath.endPoints.Item1, oldPath.endPoints.Item2);
            } catch (Exception e) {
                GUIWindow.PrintLog(e.Message);
                GUIWindow.PrintLog(e.StackTrace);
            }

            if (paths == null || paths.Count == 0)
            {
                //nie istnieje żadna ścieżka -> należy przejść wyżej lub rozłączyć jeśli jesteśmy już na górze
                return(false);
            }

            Path newPath = paths[0];

            NCC.callRegister[connectionID].path = newPath;

            string oldLCs = "";

            foreach (Connection connection in oldPath.edges)
            {
                if (ConfigLoader.myConnections.Values.Contains(connection))
                {
                    oldLCs += connection.GetID() + ", ";
                }
            }
            oldLCs = oldLCs.Remove(oldLCs.Length - 2, 2);

            string newLCs = "";

            foreach (Connection connection in newPath.edges)
            {
                if (ConfigLoader.myConnections.Values.Contains(connection))
                {
                    newLCs += connection.GetID() + ", ";
                }
            }
            newLCs = newLCs.Remove(newLCs.Length - 2, 2);

            GUIWindow.PrintLog("RC: Sent RouteTableQueryResponse(" + oldLCs + ";" + newLCs + ") to CC");       //tutaj dodać do argumentów id LC tylko z tej podsieci
            GUIWindow.PrintLog("CC: Received RouteTableQueryResponse(" + oldLCs + ";" + newLCs + ") from RC"); //tu też

            UpdateRoutingTables(oldPath, call.GetConnectionID(), false, true);
            UpdateRoutingTables(newPath, call.GetConnectionID(), false, false);
            UpdateRoutingTables(newPath, call.GetConnectionID(), true, false);

            foreach (Connection connection in oldPath.edges)
            {
                if (!ConfigLoader.myConnections.Values.Contains(connection))
                {
                    continue;
                }

                for (int i = 0; i < connection.slot.Length; i++)
                {
                    if (connection.slot[i] == connectionID)
                    {
                        connection.slot[i] = 0;
                    }
                }

                GUIWindow.PrintLog("CC: Sent LinkConnectionDeallocation(" + connection.GetID() + ") to internal LRM");
                GUIWindow.PrintLog("Internal LRM: Received LinkConnectionDeallocation(" + connection.GetID() + ") from CC");

                GUIWindow.PrintLog("Internal LRM: Sent LocalTopology(" + connection.GetID() + ": " + String.Join("", connection.slot) + ") to RC : DEALLOCATED");
                GUIWindow.PrintLog("RC: Received LocalTopology(" + connection.GetID() + ": " + String.Join("", connection.slot) + ") from Internal LRM : DEALLOCATED");
                GUIWindow.PrintLog("RC: Sent LocalTopologyResponse() to Internal LRM : OK");
                GUIWindow.PrintLog("Internal LRM: Received LocalTopologyResponse() from RC : OK");

                GUIWindow.PrintLog("Internal LRM: Sent LinkConnectionDeallocationResponse() to CC");
                GUIWindow.PrintLog("CC: Received LinkConnectionDeallocationResponse() from Internal LRM");
            }

            string[] range = oldPath.channelRange.Split('-');
            foreach (Connection connection in newPath.edges)
            {
                if (!ConfigLoader.myConnections.Values.Contains(connection))
                {
                    continue;
                }

                for (int i = Convert.ToInt32(range[0]); i <= Convert.ToInt32(range[1]); i++)
                {
                    connection.slot[i] = RC.currentConnectionID;
                }

                GUIWindow.PrintLog("CC: Sent LinkConnectionRequest(" + connection.GetID() + ", " + oldPath.channelRange + ") to internal LRM");
                GUIWindow.PrintLog("Internal LRM: Received LinkConnectionRequest(" + connection.GetID() + ", " + oldPath.channelRange + ") from CC");

                GUIWindow.PrintLog("Internal LRM: Sent LocalTopology(" + connection.GetID() + ": " + String.Join("", connection.slot) + ") to RC");
                GUIWindow.PrintLog("RC: Received LocalTopology(" + connection.GetID() + ": " + String.Join("", connection.slot) + ") from Internal LRM");
                GUIWindow.PrintLog("RC: Sent LocalTopologyResponse() to Internal LRM : OK");
                GUIWindow.PrintLog("Internal LRM: Received LocalTopologyResponse() from RC : OK");

                GUIWindow.PrintLog("Internal LRM: Sent LinkConnectionRequestResponse() to CC");
                GUIWindow.PrintLog("CC: Received LinkConnectionRequestResponse() from Internal LRM");
            }
            GUIWindow.UpdateChannelTable();

            //GUIWindow.PrintLog("Internal LRM: Sent ChannelReallocationResponse() to CC");
            //GUIWindow.PrintLog("CC: Received ChannelReallocationResponse() from Internal LRM");

            return(true);
        }