Beispiel #1
0
        public Subnet()
        {
            CC = new ConnectionController();
            RC = new RoutingController();

            subServer        = new Socket(IPAddress.Parse("127.0.0.1").AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            subClient        = new Socket(IPAddress.Parse("127.0.0.1").AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            subClientToCloud = new Socket(IPAddress.Parse("127.0.0.1").AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            //subServer.Bind(new IPEndPoint(iplocal, (int)port));
        }
Beispiel #2
0
        public static void init(ConnectionController cc, RoutingController rc, LinkResourceManager lrm)
        {
            connectionController    = cc;
            routingController       = rc;
            linkResourceManager     = lrm;
            SocketsByAddress        = new Dictionary <SubnetworkAddress, CSocket>();
            SocketsToAnotherDomains = new Dictionary <SubnetworkAddress, int>();
            String parentSubnetworkAddress = Config.getProperty("ParentSubnetworkAddress");

            if (parentSubnetworkAddress != null)
            {
                int parentSubnetworkPort = Config.getIntegerProperty("ParentSubnetworkPort");
                ConnectToParentSubnetwork(IPAddress.Parse(parentSubnetworkAddress), parentSubnetworkPort);
                SendMySubnetworkInformation();
            }
            LoadPortsToAnotherDomains();
            InitListeningCustomSocket();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            Console.Title = "Subnetwork " + CustomSocket.Config.getProperty("SubnetworkAddress");
            ConnectionController CC  = new ConnectionController();
            LinkResourceManager  LRM = new LinkResourceManager();
            RoutingController    RC  = new RoutingController(CC.ContainedSubnetworksAddresses, LRM.Links);

            SubnetworkServer.init(CC, RC, LRM);
            LoadEdgeSNPPs(CC, LRM);

            string decision;

            do
            {
                decision = Console.ReadLine().Trim();
                if (decision.StartsWith("kill"))
                {
                    string[] killParams       = decision.Split(' ');
                    string   firstSNPaddress  = killParams[1];
                    string   secondSNPaddress = killParams[2];
                    CustomSocket.LogClass.MagentaLog("Removing link: " + firstSNPaddress + " - " + secondSNPaddress);

                    List <Tuple <string, string, int> > pathsToReroute = CC.GetPathsContainingThisSNP(firstSNPaddress);
                    foreach (var path in pathsToReroute)
                    {
                        CC.DeleteConnection(path.Item1, path.Item2);
                        RC.DeleteLink(firstSNPaddress, secondSNPaddress);
                        CC.ConnectionRequestFromNCC(path.Item1, path.Item2, path.Item3);
                    }
                }
                else if (decision.StartsWith("restore"))
                {
                    string[] restoreParams     = decision.Split(' ');
                    string   firstSNPPaddress  = restoreParams[1];
                    string   secondSNPPaddress = restoreParams[2];
                    RC.RestoreLink(firstSNPPaddress, secondSNPPaddress);
                }
            }while (decision != "exit");
        }