Exemple #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));
        }
Exemple #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();
        }
Exemple #3
0
 private static void LoadEdgeSNPPs(ConnectionController cc, LinkResourceManager lrm)
 {
     string[] loaded = LoadFile(Config.getProperty("portsToDomainsFile"));
     string[] splitedParameters;
     foreach (string str in loaded)
     {
         if (str[0] != '#')
         {
             splitedParameters = str.Split(' ');
             lrm.AddEdgeSNPP(new SNPP(splitedParameters[MY_SNPP_ADDRESS], Int32.Parse(splitedParameters[MY_SNPP_CAPACITY])));
             cc.AddKeyToDictionary(new SubnetworkAddress(splitedParameters[SUBNET_ADDRESS_POSITION], splitedParameters[SUBNET_MASK_POSITION]));
         }
     }
     foreach (string str in loaded)
     {
         if (str[0] != '#')
         {
             splitedParameters = str.Split(' ');
             cc.AddValueToDictionary(new SubnetworkAddress(splitedParameters[SUBNET_ADDRESS_POSITION], splitedParameters[SUBNET_MASK_POSITION]), new Tuple <IPAddress, IPAddress>(IPAddress.Parse(splitedParameters[MY_SNPP_ADDRESS]), IPAddress.Parse(splitedParameters[EXT_SNPP_ADDRESS])));
         }
     }
 }
Exemple #4
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");
        }