コード例 #1
0
ファイル: L1M1Handler.cs プロジェクト: aorestr/TFG-Unity
 private static void SetUpR5(OpenWRT R, ushort[] NetsPrefix)
 {
     // Net interfaces
     R.ActivateInterface(IP: $"192.168.{NetsPrefix[6]}.1", interfaceNumber: 1, netmask: "255.255.255.0");
     R.ActivateInterface(IP: $"192.168.{NetsPrefix[7]}.2", interfaceNumber: 2, netmask: "255.255.255.0");
     R.ActivateInterface(IP: $"192.168.{NetsPrefix[5]}.3", interfaceNumber: 3, netmask: "255.255.255.0");
     R.DisableFirewall();
     // Routes
     R.SetRoute(destination: $"192.168.{NetsPrefix[0]}.0", gateway: $"192.168.{NetsPrefix[5]}.1", netmask: "255.255.255.0");
     R.SetRoute(destination: $"192.168.{NetsPrefix[1]}.0", gateway: $"192.168.{NetsPrefix[5]}.1", netmask: "255.255.255.0");
     R.SetRoute(destination: $"192.168.{NetsPrefix[2]}.0", gateway: $"192.168.{NetsPrefix[5]}.1", netmask: "255.255.255.0");
     R.SetRoute(destination: $"192.168.{NetsPrefix[3]}.0", gateway: $"192.168.{NetsPrefix[6]}.2", netmask: "255.255.255.0");
     R.SetRoute(destination: $"192.168.{NetsPrefix[4]}.0", gateway: $"192.168.{NetsPrefix[5]}.1", netmask: "255.255.255.0");
 }
コード例 #2
0
ファイル: L1M1Handler.cs プロジェクト: aorestr/TFG-Unity
    // Use this for initialization
    void Awake()
    {
        // Activate nodes
        foreach (string nodeName in L1Mapping.NodeNamesM1)
        {
            GNS3Handler.Instance.projectHandler.StartNode(
                GNS3Handler.Instance.projectHandler.GetNodeByName(nodeName)
                );
        }
        // Initialize a Stopwatch instance in order to measure times
        //Stopwatch stopWatch = new Stopwatch();
        // Assign every node with a variable
        VPC     PC1 = (VPC)GNS3Handler.Instance.projectHandler.GetNodeByName(L1Mapping.NodeNamesM1[0]);
        VPC     PC2 = (VPC)GNS3Handler.Instance.projectHandler.GetNodeByName(L1Mapping.NodeNamesM1[1]);
        OpenWRT R1  = (OpenWRT)GNS3Handler.Instance.projectHandler.GetNodeByName(L1Mapping.NodeNamesM1[2]);
        OpenWRT R2  = (OpenWRT)GNS3Handler.Instance.projectHandler.GetNodeByName(L1Mapping.NodeNamesM1[3]);
        OpenWRT R3  = (OpenWRT)GNS3Handler.Instance.projectHandler.GetNodeByName(L1Mapping.NodeNamesM1[4]);
        OpenWRT R4  = (OpenWRT)GNS3Handler.Instance.projectHandler.GetNodeByName(L1Mapping.NodeNamesM1[5]);
        OpenWRT R5  = (OpenWRT)GNS3Handler.Instance.projectHandler.GetNodeByName(L1Mapping.NodeNamesM1[6]);

        OpenWRT[] Routers = new OpenWRT[5] {
            R1, R2, R3, R4, R5
        };

        // We need to wait. Otherwise, nodes won't boot properly. We have set 4:30
        Thread.Sleep(270000);

        // Set up end-point nodes
        L1M1HandlerHelper.SetUpPCs(new VPC[2] {
            PC1, PC2
        }, NetsPrefix);

        /*
         * stopWatch.Start();
         * L1M1HandlerHelper.SetUpPCs(new VPC[2] { PC1, PC2 }, NetsPrefix);
         * using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\aores\Desktop\caso2.txt"))
         * {
         *  file.WriteLine($"Milisegundos en preparar los VPCs: {stopWatch.ElapsedMilliseconds.ToString()}");
         * }
         * stopWatch.Stop();
         */

        // Set-up routers
        L1M1HandlerHelper.SetUpRouters(Routers, NetsPrefix);

        /*
         * stopWatch.Start();
         * L1M1HandlerHelper.SetUpRouters(Routers, NetsPrefix);
         * using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\aores\Desktop\caso2.txt", true))
         * {
         *  file.WriteLine($"Milisegundos en preparar los routers: {stopWatch.ElapsedMilliseconds.ToString()}");
         * }
         * stopWatch.Stop();
         */

        // Set the routing tables signs
        for (int i = 0; i < Routers.Length; i++)
        {
            L1M1HandlerHelper.SetRoutingTables(Routers[i].RoutingTable, NetTables[i]);
        }

        /*
         * stopWatch.Start();
         * for (int i = 0; i < Routers.Length; i++)
         *  L1M1HandlerHelper.SetRoutingTables(Routers[i].RoutingTable, NetTables[i]);
         * using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\aores\Desktop\caso2.txt", true))
         * {
         *  file.WriteLine($"Milisegundos en preparar las tablas de encaminamiento del juego: {stopWatch.ElapsedMilliseconds.ToString()}");
         * }
         * stopWatch.Stop();
         */

        // IP of the PC2
        DestinationIP.text = $"Dest:192.168.{NetsPrefix[NetsPrefix.Length - 1]}/24";
        StartCoroutine("Timer");
    }